How can i make my player look at the same direction where its moving? [JOYSTICK ANDROID]
Hey!
I'm making a topdown combat/shooter game on android. It takes joystick input for movement, but currently i can only move the player object but not the direction where its looking at...
I want to make it so that it would look at the same direction that its moving. Can anyone help me?
Heres my script for the player.
public class MyScript : MonoBehaviour {
 public float moveSpeed = 5f;
 protected Joystick joyStick;
 protected JoyButton joyButton;
 public bool isGrounded = false;
 public Transform target;
 protected bool jump;
 
 void Start()
 {
     Rigidbody player = GetComponent<Rigidbody>();
     joyStick = FindObjectOfType<Joystick>();
     joyButton = FindObjectOfType<JoyButton>();
 }
 void FixedUpdate()
 {
     
     var rigidbody = GetComponent<Rigidbody>();
     rigidbody.velocity = new Vector3(joyStick.Horizontal * moveSpeed + Input.GetAxisRaw("Horizontal") * moveSpeed, rigidbody.velocity.y, joyStick.Vertical * moveSpeed + Input.GetAxisRaw("Vertical") * moveSpeed);
    
     if (isGrounded == true)
     {
         if (!jump && (joyButton.Pressed || Input.GetButtonDown("Jump")))
         {
             jump = true;
             rigidbody.velocity += Vector3.up * moveSpeed;
         }
         if (jump && (!joyButton.Pressed || Input.GetButtonDown("Jump")))
         {
             jump = false;
         }
     }
 }
 private void OnCollisionEnter(Collision theCollision)
 {
     if (theCollision.gameObject.name == "Ground")
     {
         isGrounded = true;
     }
 }
 private void OnCollisionExit(Collision theCollision)
 {
     if (theCollision.gameObject.name != "floor")
     {
         isGrounded = false;
     }
 }
}
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                