Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

Rigidbody movement conflict?

$
0
0
Hello guys! I've got a problem. When I hold AWSD then hold spacebar, it just ends up with the character getting up a little from the ground then going back to normal, like as if nothing happened! Is there some way to fix this? Here is my script: function OnTriggerStay () { Jumped = false; } function FixedUpdate () { //Player movement if(Input.GetKey(KeyCode.Space) && !Jumped) { Jumped = true; rigidbody.AddForce(Vector3.up * JumpHeight); } if(Input.GetKey(KeyCode.W)) rigidbody.velocity = transform.forward * Forward * Time.deltaTime; if(Input.GetKey(KeyCode.S)) rigidbody.velocity = transform.forward * -MoveSpeed * Time.deltaTime; if(Input.GetKey(KeyCode.D)) rigidbody.velocity = transform.right * MoveSpeed * Time.deltaTime; if(Input.GetKey(KeyCode.A)) rigidbody.velocity = transform.right * -MoveSpeed * Time.deltaTime; //Player run movement if(Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { if(Input.GetKey(KeyCode.W)) rigidbody.velocity = transform.forward * ForwardRun * Time.deltaTime; if(Input.GetKey(KeyCode.S)) rigidbody.velocity = transform.forward * -RunSpeed * Time.deltaTime; if(Input.GetKey(KeyCode.D)) rigidbody.velocity = transform.right * RunSpeed * Time.deltaTime; if(Input.GetKey(KeyCode.A)) rigidbody.velocity = transform.right * -RunSpeed * Time.deltaTime; } } I'm guessing it's because I'm using rigidbody movement for both commands? Sorry, only started Unity about a week ago.

Viewing all articles
Browse latest Browse all 1264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>