• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Broccoliguy04 · Oct 12, 2017 at 03:20 AM · scripting problemgetbuttondown

KeyNotFoundException:The given key was not present in the dictionary.

So I was just kind of practicing my skills, but I ran into a problem that I couldn't find the answer to ( it may be a simple fix). It has to do with Input.GetKeyDown. So the error I get is this. KeyNotFoundException:The given key was not present in the dictionary. If you find the problem I will very grateful to you. Thanks! Here is my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PortalMove : MonoBehaviour {

 public Animator anim;


 // Use this for initialization
 void Start () {
     anim = GetComponent<Animator>();
 }
 
 // Update is called once per frame
 void Update () {
     bool move = Input.GetButtonDown("Jump");
     anim.SetBool ("Stop", move);
 }

}
(BTW, I am pretty sure it is line 11 (the bool line) that is the problem)

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Hellium · Oct 12, 2017 at 07:15 AM 0
Share

Are you sure your animator has a Stop parameter? (Which is different from a Stop state). $$anonymous$$ake sure you haven't mispelled the parameter name (example stop != Stop)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Injec · Oct 12, 2017 at 02:04 PM

Hey, it means, that the key "Jump" of the dictionary doesn't exist. Have a look at your InputManager and look, if the key exists in there.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Hellium · Oct 12, 2017 at 02:09 PM 0
Share

The error would be the following if the problem came from the Input$$anonymous$$anager :

ArgumentException: Input Button Jump is not setup. To change the input settings use: Edit -> Project Settings -> Input

avatar image Injec · Oct 12, 2017 at 02:17 PM 0
Share

Oh yeah, right. Then it is probable the key of the animator. So is there a key named "Stop" in your animator? Do you maybe get the wrong Animator? or is "Stop" written in small letters in you animator?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

128 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

GetButtonDown problem | C# 0 Answers

Error on script for detecting the terrain texture 2 Answers

Set active false the second box collider... 3 Answers

Infinite repetition, need help 1 Answer

How can i create a Plane using this Mesh generator script ? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges