Space Shooter - Player Stuck in x boundaries
Hello Everyone,
I'm trying to do the Space Shooter Tutorial in Unity 2017. After setting the bounds, when I enter Playmode, my player get stuck in the x bounds, continuously going from x6 to x-6. I can't move it in other x values. However, I can move it in the z axis.
Does anyone here has had the same issue?
Here is my code, I must be doing something wrong but I can't figure it out :
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 [System.Serializable]
 public class Boundary
 {
     public float xMin, xMax, zMin, zMax; 
 }
 public class PlayerControler : MonoBehaviour
 {
     public Rigidbody rb;
     public float speed;
     public Boundary boundary;
 
     void Start ()
     {
         rb = GetComponent<Rigidbody> ();
     }
 
     void Update ()
     {
 
     }
 
     void FixedUpdate ()
     {
         float moveHorizontal = Input.GetAxis ("Horizontal");
         float moveVertical = Input.GetAxis ("Vertical");
 
         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
 
         rb.velocity = movement * speed;
 
         rb.position = new Vector3
             (
                 Mathf.Clamp (rb.position.x, boundary.xMin, boundary.xMax),
                 0.0f,
                 Mathf.Clamp (rb.position.z, boundary.zMin, boundary.zMax)
             );
 
     }                 
 }
 
               Thanks.
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Which Unity Tutorials should I watch? 0 Answers
Can't score points 1 Answer
Unity-Chan animation hands 0 Answers
is it legal to remake games of unity tutoriald and publishing them? 0 Answers