- Home /
 
 
               Question by 
               AmitNz · Mar 10, 2017 at 02:39 PM · 
                rotationcontroller  
              
 
              How to keep the right sides while rotation
Hi everyone, I'm trying to write a basic FPS controller script and I'm having a problem that when I rotate the player with the mouse The sides are inverting. How can I fix it ?
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class playerController : MonoBehaviour {
     //Declerations
     public float speed = 5f;
     public float rSpeed = 5f;
     Rigidbody rb;
      
     // Use this for initialization
     void Awake ()
     {
         rb = GetComponent<Rigidbody>();
         rb.freezeRotation = true;
     }
 
     void Update()
     {
         Vector3 velocity = new Vector3(Input.GetAxis("Horizontal"), 0f, Input.GetAxis("Vertical"));
         transform.Rotate(new Vector3(0, Input.GetAxis("Mouse X"), 0) * Time.deltaTime * rSpeed);
         transform.position += (velocity * speed * Time.deltaTime);
     }
    
 }
 
 
              
               Comment
              
 
               
              Your answer