Question by 
               caldisney07 · Apr 08, 2020 at 07:16 PM · 
                c#movementunity 2dmovement script  
              
 
              How can I get the player to face the direction it is going in a Unity 2D Game?
Hi. How can I get the player to face the direction it is going in a Unity 2D Game?
I have looked all over the Internet for an answer, and I can't find anything that works.
The code I am using is
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class playerMovement : MonoBehaviour
 {
 
     Rigidbody2D body;
     Transform target;
 
     float horizontal;
     float vertical;
     float moveLimiter = 0.7f;
     private bool facingRight;
 
     public float runSpeed = 20.0f;
 
     void Start ()
     {
         body = GetComponent<Rigidbody2D>();
     }
 
     void Update()
     {
         // Gives a value between -1 and 1
         horizontal = Input.GetAxisRaw("Horizontal"); // -1 is left
         vertical = Input.GetAxisRaw("Vertical"); // -1 is down
     }
 
     void FixedUpdate()
     {
         if (horizontal != 0 && vertical != 0) // Check for diagonal movement
         {
             // limit movement speed diagonally, so you move at 70% speed
             horizontal *= moveLimiter;
             vertical *= moveLimiter;
         } 
 
         body.velocity = new Vector2(horizontal * runSpeed, vertical * runSpeed);
     }
     }
 
               If anybody could help me, it would be much appreciated.
Thanks. :)
               Comment
              
 
               
              Your answer