Question by 
               Liraseth · Oct 16, 2019 at 05:31 PM · 
                movementplayermovement scriptplayer movementair  
              
 
              Reduce Player Movement in Air
For now I have a ball that can move forwards, backwards, left, right and up but when the ball jumps it can still be controlled in the air. I wish to reduce the movement control in the air but not remove it entirely. This is my script so far...
{
 public float speed = 20;
 private Rigidbody rb;
 bool isGrounded = true;
 public float jump = 300f;
 void Start()
 {
     rb = GetComponent<Rigidbody>();
 }
 void FixedUpdate()
 {
     Vector3 movement;
     float moveHorizontal = Input.GetAxis("Horizontal");
     float moveVertical = Input.GetAxis("Vertical");
     GameObject cameraCompass = new GameObject("Camera Compass");
     cameraCompass.transform.eulerAngles = new Vector3(0, GameObject.FindGameObjectWithTag("MainCamera").transform.eulerAngles.y, 0f);
     Vector3 movementX = cameraCompass.transform.right * moveHorizontal;
     Vector3 movementZ = cameraCompass.transform.forward * moveVertical;
     movement = movementX + movementZ;
     rb.AddForce(movement * speed);
     
     Destroy(cameraCompass); 
 }
 private void Update()
 {
     bool player_jump = Input.GetButtonDown("Jump");
     if (player_jump && isGrounded)
     {
         rb.AddForce(Vector3.up * jump);
     }
 }
 void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.CompareTag("Ground"))
     {
         isGrounded = true;
     }
 }
 void OnCollisionExit(Collision collision)
 {
     if (collision.gameObject.CompareTag("Ground"))
     {
         isGrounded = false;
     }
 }
}
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
How to move 3 players at the same time in V form,How to move 3 characters in the same time in V form 0 Answers
Player only moves when the key is pressed, not when it's held. 0 Answers
Dash Movement Platformer 0 Answers
Moving simultaneously with UP LEFT, W D using GetAxisRaw. Rotating localScale to flip animation 2 Answers
Object rotates when moving sideways 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                