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.
- This topic has 15 replies, 2 voices, and was last updated 2 months, 1 week ago by
Mike1nator.
-
AuthorPosts
-
May 7, 2024 at 12:35 am #14529
Mike1nator
ParticipantThis 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” stopsi tried using the
print(am.GetBool("Move"));
as i’ve seen someone suggested and i get thisFalse 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?
May 7, 2024 at 9:27 am #14540Terence
KeymasterDo 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.
May 7, 2024 at 12:32 pm #14547Mike1nator
ParticipantYes 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.
May 7, 2024 at 2:02 pm #14550Terence
KeymasterIs 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.
May 7, 2024 at 11:52 pm #14552Mike1nator
ParticipantI think you mean these?
I don’t know what you mean by “controller” which one is it
May 7, 2024 at 11:57 pm #14553Terence
KeymasterCheck the Controller variable in your Animator component (not the Window, the component on the GameObject). You probably assigned the wrong Controller asset to it.
May 8, 2024 at 12:02 am #14554Mike1nator
ParticipantThe 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
May 8, 2024 at 9:54 am #14557Terence
KeymasterThe 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.
May 11, 2024 at 9:45 pm #14627Mike1nator
ParticipantThis?
“plyaer” is the name of the character ( i typed it wrong and didn’t change it)
May 12, 2024 at 1:19 pm #14630Terence
KeymasterWhat 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.
May 12, 2024 at 7:39 pm #14636Mike1nator
Participantif 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:
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
May 13, 2024 at 5:05 pm #14638Terence
KeymasterHi 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?
May 15, 2024 at 3:22 am #14661Mike1nator
Participanthere is the link for the whole project
linkMay 15, 2024 at 11:02 am #14663Terence
KeymasterMike, 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.
May 15, 2024 at 10:56 pm #14675Mike1nator
ParticipantSo 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.
-
AuthorPosts
- You must be logged in to reply to this topic.
Advertisement below: