using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 5f;
public Rigidbody2D rb;
public Vector2 movement;
public Animator anim;
public void Start()
{
anim.SetBool("IsMoving", false);
}
// Update is called once per frame
public void Update()
{
//Input
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
if (movement.x == 0 && movement.y == 0)
{
anim.SetBool("IsMoving", false);
}
if(movement.x != 0 || movement.y != 0 || movement.x != 0 && movement.y !=0)
{
anim.SetBool("IsMoving", true);
}
}
void FixedUpdate()
{
//Movement
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
}
}