Question by 
               nisan4041 · Sep 23, 2019 at 03:55 PM · 
                c#rigidbodycharactercontrollermovement scriptcharacter movement  
              
 
              Player still move left&right in MenuUI
Hello everyone! In my game in menu page my player don't move forward but he can still move left&right and I don't want that.Can someone help me?
Player movement script:
 void Update () {
         playerSpeed = playerSpeed + 1f;
 #if UNITY_EDITOR || UNITY_STANDALONE || UNITY_WEBPLAYER 
         float moveHorizontal = Input.GetAxis("Horizontal");
         transform.position = Vector3.Lerp(gameObject.transform.position, new Vector3(Mathf.Clamp(gameObject.transform.position.x
 + moveHorizontal, -2.5f, 2.5f), gameObject.transform.position.y, gameObject.transform.position.z), directionalSpeed * Time.deltaTime);
 #endif
         GetComponent<Rigidbody>().velocity = Vector3.forward * playerSpeed * Time.deltaTime;
         transform.Rotate(Vector3.right * GetComponent<Rigidbody>().velocity.z / 3);
         //MOBILE CONTROLS
         Vector2 touch = Camera.main.ScreenToWorldPoint(Input.mousePosition
 + new Vector3(0, 0, 10f));
         if (Input.touchCount > 0) {
             transform.position = new Vector3(touch.x, transform.position.y, transform.position.z);
         }     }
 
               Player stop movement in menu script:
 void Start () {
         player.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezePosition;
         inMenuUI.gameObject.SetActive(true);
         inGameUI.gameObject.SetActive(false);
         gameOverUI.gameObject.SetActive(false);
     }
 
              
               Comment
              
 
               
              Your answer