I’ve tryed hard for the last few days trying to fix what is wrong with my walking + animation script. I’ve tryed every recent tutorial on youtube but nothing has worked.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player_controler1 : MonoBehaviour
{
public float movSpeed;
float speedX, speedY;
Rigidbody2D rb;
public Animator animator;
Vector2 movement;
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
speedX = Input.GetAxisRaw("Horizontal") * movSpeed;
speedY = Input.GetAxisRaw("Vertical") * movSpeed;
rb.velocity = new Vector2(speedX, speedY);
animator.SetFloat("Horizontal", movement.x);
animator.SetFloat("Vertical", movement.y);
animator.SetFloat("Speed", movement.sqrMagnitude);
}
}