- Home /
 
               Question by 
               n3wb13 · May 12, 2018 at 08:22 AM · 
                rotationmovementquaternion.lookrotation  
              
 
              How to rotate a character towards its movement direction for a walk on planet game?
I've tried transform.rotation = Quaternion.LookRotation(moveDirection); but it's not working for this type of game.
I achieved this walk on planet behavior by following this tutorial https://www.youtube.com/watch?v=TicipSVT-T8 However, I modified it since I don't want a first person version. Source code for this reference video https://github.com/SebLague/Spherical-Gravity
 public class PlayerController : MonoBehaviour {
     
         public float moveSpeed = 3.0f;
         Rigidbody myRB;
         Vector3 moveAmount;
         Vector3 smoothMoveVelocity;
     
         void Start() {
             myRB = GetComponent<Rigidbody>();
         }
     
     
         void Update() {
                 Vector3 moveDir = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")).normalized;
                 Vector3 targetMoveAmount = moveDir * moveSpeed;
                 
                 moveAmount = Vector3.SmoothDamp(moveAmount, targetMoveAmount, ref smoothMoveVelocity, Time.deltaTime);
     
                 if (moveAmount != Vector3.zero)
                     //Rotate player towards movement direction
     
         }
     
         private void FixedUpdate() {           
              myRB.MovePosition(myRB.position + transform.TransformDirection(moveAmount) * Time.fixedDeltaTime);
         }
     }
 
 
 
  
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                