Forum begins after the advertisement:


[Part 1] Parameter ‘Move’ does not exist.

Home Forums Video Game Tutorial Series Creating a Rogue-like Shoot-em Up in Unity [Part 1] Parameter ‘Move’ does not exist.

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #14529
    Mike1nator
    Level 3
    Participant
    Helpful?
    Up
    0
    ::

    This is PlayerMovement.cs

    public class PlayerMovement : MonoBehaviour
    {
        //movement
        public float moveSpeed;
        Rigidbody2D rb;
        [HideInInspector]
        public Vector2 moveDir;
    
        void Start()
        {
            rb = GetComponent<Rigidbody2D>();
        }
    
        void Update()
        {
            InputManagement();
        }
    
        void FixedUpdate()
        {
            Move();
        }
        void InputManagement()
        {
            float moveX = Input.GetAxisRaw("Horizontal");
            float moveY = Input.GetAxisRaw("Vertical");
    
            moveDir = new Vector2(moveX, moveY).normalized;
        }
    
        void Move()
        {
            rb.velocity = new Vector2(moveDir.x * moveSpeed, moveDir.y * moveSpeed);
        }
    }

    And this is PlayerAnimator.cs

    public class PlayerAnimator : MonoBehaviour
    {
        //Reference
        Animator am;
        PlayerMovement pm;
        SpriteRenderer sr;
        
        
        
        // Start is called before the first frame update
        void Start()
        {
            am = GetComponent<Animator>();
            pm = GetComponent<PlayerMovement>();
            sr = GetComponent<SpriteRenderer>();
        }
    
        // Update is called once per frame
        void Update()
        {
            if (pm.moveDir.x != 0 || pm.moveDir.y != 0)
            {
                am.SetBool("Move" , true);
    
                SpriteDirectionChecker();
            }
            else
            {
                am.SetBool("Move" , false);
            }
        }
    
        void SpriteDirectionChecker()
        {
            if (pm.moveDir.x < 0)
            {
                sr.flipX = true;
            }
            else
            {
                sr.flipX = false;
            }    
        }
    }

    When pressing play i get spammed with this

    "Parameter 'Move' does not exist.
    UnityEngine.Animator:SetBool (string,bool)
    PlayerAnimator:Update () (at Assets/scripts/PlayerAnimator.cs:33)"

    even though it says line 33, the first setBool from line 27 doesn’t work either
    if i disable the PlayerAnimator script the “error” stops

    i tried using the print(am.GetBool("Move")); as i’ve seen someone suggested and i get this

    False
    UnityEngine.MonoBehaviour:print (object)
    PlayerAnimator:Update () (at Assets/scripts/PlayerAnimator.cs:35)

    So i guess the move function is working since my character moves on the screen but the animator doesn’t see it? since the walking animation isn’t there.

    Any help?

    #14540
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Do you have the Move parameter in your Animator parameters? You have to ensure that it is spelled the same as the “Move” string in your code.

    Animator Parameters

    #14547
    Mike1nator
    Level 3
    Participant
    Helpful?
    Up
    0
    ::

    Yes i have it In that menu, i can toggle it on and the walking animation will start, but the error message still appears. It is spelled “Move” no spaces.

    #14550
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Is your Animator component assigned the correct Animator Controller? You may have multiple Controllers and have assigned the wrong one (i.e. the one without “Move”) to your Animator.

    #14552
    Mike1nator
    Level 3
    Participant
    Helpful?
    Up
    0
    ::

    I think you mean these?

    View post on imgur.com

    I don’t know what you mean by “controller” which one is it

    #14553
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Check the Controller variable in your Animator component (not the Window, the component on the GameObject). You probably assigned the wrong Controller asset to it.

    #14554
    Mike1nator
    Level 3
    Participant
    Helpful?
    Up
    0
    ::

    The right controller is set.

    I messed with some options and in the parameter field i can see that when moving, the animator never leaves the “idle” state so the problem is the whole move condition. And it never switches to move = true

    #14557
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    The right controller is set.

    I messed with some options and in the parameter field i can see that when moving, the animator never leaves the “idle” state so the problem is the whole move condition. And it never switches to move = true

    Can you double click on the Animator to open it and check just in case? The only way I can see that the “Parameter doesn’t exist error” occurs is if the Parameter is not in the Controller.

    #14627
    Mike1nator
    Level 3
    Participant
    Helpful?
    Up
    0
    ::

    This?

    View post on imgur.com

    “plyaer” is the name of the character ( i typed it wrong and didn’t change it)

    #14630
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    What happens when you double click into this plyaer object?

    By the way, when you want to embed Imgur images, just paste the link on your post like this:

    https://imgur.com/a/BGiHy47

    It will automatically convert the link to an Imgur image. You don’t need to copy the embed code from Imgur — that will get your post flagged as spam.

    #14636
    Mike1nator
    Level 3
    Participant
    Helpful?
    Up
    0
    ::

    if you mean double clicking into that field, it just opens the animator window that i posted.

    This is what i see if i click on the dot to change the controller:

    View post on imgur.com

    Double clicking on the character in the scene window doesn’t do anything

    Well, it looks like “plyaer” isn’t my character, it is placed in the Animations Folder and it says “(Animator Controller)” in the inspector window

    #14638
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Hi Mike, if your issue is still not fixed, I’m gonna need to see your project files to pinpoint your issue. I’m not sure why the error is popping, because everything seems to be set up correctly on your end.

    Can you upload your files onto Drive and share the link here?

    #14661
    Mike1nator
    Level 3
    Participant
    Helpful?
    Up
    0
    ::

    here is the link for the whole project
    link

    #14663
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Mike, in your Animator Controller, you defined the “move” parameter, but you are trying to access the “Move” parameter in your code — Animator parameters are case sensitive so you have to make sure the spellings match.

    #14675
    Mike1nator
    Level 3
    Participant
    Helpful?
    Up
    0
    ::

    So there wasn’t even a problem in the code, just the little thing that i had to double click and capitalize the “m”

    It works now thanks for the help. I know i wrote “move” in the code and then changed it when i saw he edited his code off camera in the video.

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: