Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Parameter "Jump" does not exist

Discussion in 'Scripting' started by ybaGG, Feb 14, 2021.

  1. ybaGG

    ybaGG

    Joined:
    Jan 28, 2021
    Posts:
    42
    Hey there,
    How's it going?

    Well, I'm making my first 2D platform game and it is going well so far,
    but I got this error and it is disturbing me for real... I hope someone can help me,
    cause it's very boring.

    The error says:
    Parameter 'Jump' does not exist.
    UnityEngine.Animator:SetBool(String, Boolean)
    Player:Jump() (at Assets/Pixel Adventure 1/Assets/Scripts/Player.cs:64)
    Player:Update() (at Assets/Pixel Adventure 1/Assets/Scripts/Player.cs:28)

    It says that is something wrong with my Player's Scripts...
    here's the code:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class Player : MonoBehaviour
    6. {
    7.  
    8.     public float Speed;
    9.     public float JumpForce;
    10.  
    11.     public bool isJumping;
    12.     public bool doubleJump;
    13.  
    14.     private Rigidbody2D rig;
    15.     private Animator anim;
    16.  
    17.     // Start is called before the first frame update
    18.     void Start()
    19.     {
    20.         rig = GetComponent<Rigidbody2D>();
    21.         anim = GetComponent<Animator>();
    22.     }
    23.  
    24.     // Update is called once per frame
    25.     void Update()
    26.     {
    27.         Move();
    28.         Jump();
    29.     }
    30.  
    31.     void Move()
    32.     {
    33.         Vector3 movement = new Vector3(Input.GetAxis("Horizontal"), 0f, 0f);
    34.         transform.position += movement * Time.deltaTime * Speed;
    35.  
    36.         if (Input.GetAxis("Horizontal") > 0f)
    37.         {
    38.             anim.SetBool("walk", true);
    39.             transform.eulerAngles = new Vector3(0f, 0f, 0f);
    40.         }
    41.  
    42.         if (Input.GetAxis("Horizontal") < 0f)
    43.         {
    44.             anim.SetBool("walk", true);
    45.             transform.eulerAngles = new Vector3(0f, 180f, 0f);
    46.  
    47.         }
    48.  
    49.         if (Input.GetAxis("Horizontal") == 0f)
    50.         {
    51.             anim.SetBool("walk", false);
    52.  
    53.         }
    54.     }
    55.  
    56.     void Jump()
    57.     {
    58.         if (Input.GetButtonDown("Jump"))
    59.         {
    60.             if (!isJumping)
    61.             {
    62.                 rig.AddForce(new Vector2(0f, JumpForce), ForceMode2D.Impulse);
    63.                 doubleJump = true;
    64.                 anim.SetBool("Jump", true);
    65.             }
    66.             else
    67.             {
    68.                 if (doubleJump)
    69.                 {
    70.                     rig.AddForce(new Vector2(0f, JumpForce), ForceMode2D.Impulse);
    71.                     doubleJump = false;
    72.                 }
    73.             }
    74.             rig.AddForce(new Vector2(0f, JumpForce), ForceMode2D.Impulse);
    75.         }
    76.     }
    77.  
    78.  
    79.     void OnCollisionEnter2D(Collision2D collision)
    80.     {
    81.         if (collision.gameObject.layer == 8)
    82.         {
    83.             isJumping = false;
    84.             anim.SetBool("jump", false);
    85.         }
    86.     }
    87.  
    88.     void OnCollisionExit2D(Collision2D collision)
    89.     {
    90.         if (collision.gameObject.layer == 8)
    91.         {
    92.             isJumping = true;
    93.         }
    94.     }
    95. }
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,762
    Perhaps this is true, but this is NOT what it is saying.

    Read the error carefully. It is saying that when you try to say
    SetBool( "Jump", true);
    your animator has not been set up to have a boolean property named "Jump".

    Go back to the tutorial or guide where all this started from and make sure you don't skip the part where they have you set up the animator. In Unity code is almost never alone in a vacuum, and almost always interoperates with other assets and systems, in this case the
    Animator
    found on this
    GameObject
    during the
    Start()
    function's execution phase.
     
  3. ybaGG

    ybaGG

    Joined:
    Jan 28, 2021
    Posts:
    42
    Just solved it, the problem was that I have switched "jump" to "walk" on 2 conditions... silly mistake lol
    Thx anyway :)
     
  4. ybaGG

    ybaGG

    Joined:
    Jan 28, 2021
    Posts:
    42
    Do you know what this error means? I googled it, but didn't find a solution...
    A guy told me it is just an engine glitch and there's nothing to worry about, but
    I don't like to see alerts on my Console...

    The alert says:
    NullReferenceException: Object reference not set to an instance of an object
    UnityEditor.Graphs.Edge.WakeUp () (at <732b665a0eb44a80b9931c01ad63f8b8>:0)
    UnityEditor.Graphs.Graph.DoWakeUpEdges (System.Collections.Generic.List`1[T] inEdges, System.Collections.Generic.List`1[T] ok, System.Collections.Generic.List`1[T] error, System.Boolean inEdgesUsedToBeValid) (at <732b665a0eb44a80b9931c01ad63f8b8>:0)
    UnityEditor.Graphs.Graph.WakeUpEdges (System.Boolean clearSlotEdges) (at <732b665a0eb44a80b9931c01ad63f8b8>:0)
    UnityEditor.Graphs.Graph.WakeUp (System.Boolean force) (at <732b665a0eb44a80b9931c01ad63f8b8>:0)
    UnityEditor.Graphs.Graph.WakeUp () (at <732b665a0eb44a80b9931c01ad63f8b8>:0)
    UnityEditor.Graphs.Graph.OnEnable () (at <732b665a0eb44a80b9931c01ad63f8b8>:0)
     
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,762
    Normally this means you didn't set something up and it is a super-common error.

    But looking where this one is coming from (the lines below it, the call stack), it appears this one is happening entirely internal to Unity.

    This came up in Google:

    https://forum.unity.com/threads/what-is-this-big-error-im-getting.324597/
     
  6. ybaGG

    ybaGG

    Joined:
    Jan 28, 2021
    Posts:
    42
    Got it!
    Thx for helping me
     
  7. Wade2121

    Wade2121

    Joined:
    Apr 23, 2022
    Posts:
    1

    Thank you so much I was losing my S*** until I found your answer.
     
    Kurt-Dekker likes this.