So I got this error in my code and now all my animations just refuse to work, I have been stuck at this issue for over a day now, and just got so tired of helpless fixing that I am asking for yall to help my stupidity.
Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
[Header(“Config”)]
[SerializeField] private float speed;
private PlayerActions actions;
private Rigidbody2D rb2D;
private PlayerAnimations playerAnimations;
private Vector2 moveDirection;
private void Awake()
{
actions = new PlayerActions();
rb2D = GetComponent<Rigidbody2D>();
playerAnimations = GetComponent<PlayerAnimations>();
}
private void Update()
{
ReadMovement();
}
private void FixedUpdate()
{
Move();
}
private void Move()
{
rb2D.MovePosition(rb2D.position + moveDirection * (speed * Time.fixedDeltaTime));
}
private void ReadMovement()
{
moveDirection = actions.Movement.Move.ReadValue<Vector2>().normalized;
if (moveDirection == Vector2.zero)
{
playerAnimations.SetMovingAnimation(false);
return;
}
playerAnimations.SetMovingAnimation(true);
playerAnimations.SetMoveAnimation(moveDirection);
}
private void OnEnable()
{
actions.Enable();
}
private void OnDisable()
{
actions.Disable();
}
}
This is the other animation side:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAnimations : MonoBehaviour
{
private readonly int moveX = Animator.StringToHash(“MoveX”);
private readonly int moveY = Animator.StringToHash(“MoveY”);
private readonly int moving = Animator.StringToHash(“Moving”);
private readonly int dead = Animator.StringToHash(“Dead”);
private Animator animator;
private void Awake()
{
animator = GetComponent<Animator>();
}
public void SetDeadAnimation()
{
animator.SetTrigger(dead);
}
public void SetMovingAnimation(bool value)
{
animator.SetBool(moving, value);
}
public void SetMoveAnimation(Vector2 dir)
{
animator.SetFloat(moveX, dir.x);
animator.SetFloat(moveY, dir.y);
}
}