using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerContorller : MonoBehaviour
{
public float speed;
public Animator animator;
private Rigidbody2D rb;
private Vector2 direction;
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void FixedUpdate()
{
direction.x = Input.GetAxisRaw("Horizontal");
direction.y = Input.GetAxisRaw("Vertical");
animator.SetFloat("Horizontal", direction.x);
animator.SetFloat("Vertical", direction.y);
animator.SetFloat("Speed", direction.sqrMagnitude);
rb.velocity = new Vector2(direction.x, direction.y);
}
}