How do i flip my character to face in the direction hes moving
Im new to unity and C# and im completely lost on how to flip my character. plz help!
public class PlayerController : MonoBehaviour
{
public float moveSpeed = 5f;
public bool isGrounded = false;
void Start()
{
}
void Update()
{
Jump(); // Allows The player to Jump
Vector3 movement = new Vector3(Input.GetAxisRaw("Horizontal"), 0f, 0f);
transform.position += movement * Time.deltaTime * moveSpeed; //Allows player to move left and right
}
void Jump()
{
if (Input.GetButtonDown("Jump") && isGrounded == true)
{
gameObject.GetComponent<Rigidbody2D>().AddForce(new Vector2(0f, 5f), ForceMode2D.Impulse);
}
}
}
,Im new to unity and C# and im completely lost on how to flip my character depending on what direction he is facing. What should i add to this script to make him flip the other direction. plz help!
public class PlayerController : MonoBehaviour { public float moveSpeed = 5f; public bool isGrounded = false; void Start() { } void Update() { Jump(); // Allows The player to Jump Vector3 movement = new Vector3(Input.GetAxisRaw("Horizontal"), 0f, 0f); transform.position += movement * Time.deltaTime * moveSpeed; //Allows player to move left and right } void Jump() { if (Input.GetButtonDown("Jump") && isGrounded == true) { gameObject.GetComponent<Rigidbody2D>().AddForce(new Vector2(0f, 5f), ForceMode2D.Impulse); } } } ,
Your answer