using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Move1 : MonoBehaviour
{
float speed = 5.0f;
Rigidbody2D rb;
bool FacingRight = true;
int directionInput;
public bool ground = false;
public float jumpForce = 100f;
Animator animator;
void Start()
{
rb = GetComponent<Rigidbody2D>();
animator = GetComponent<Animator>();
}
void FixedUpdate()
{
rb.velocity = new Vector2(speed * directionInput, rb.velocity.y);
if (directionInput<0 && FacingRight)
{
Flip();
}
else if (directionInput > 0 && !FacingRight)
{
Flip();
}
}
public void Move(int InputAxis)
{
directionInput = InputAxis;
if (speed == 0.0f)
{
animator.SetBool("Run", false);
}
else
{
animator.SetBool("Run", true);
}
}
void Flip()
{
FacingRight = !FacingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
public void Jump()
{
if (ground == true)
rb.AddForce(Vector2.up * jumpForce);
animator.SetTrigger("Jump");
}
}
,my charaster dont stops running if he stopped
heres my code