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

How do I stop an object from jumping VERY high at first?

$
0
0
Hi guys! So I have a problem with my player GameObject. Every time I do my "Jump" command at the **start of the game,** it manages to jump ridiculously high. But after that, it starts jumping normally again. Is there some way I can prevent that from happening? Thank you in advance. Oh, and here's my "Jump" command script: var Jumped = false; var JumpHeight = 7500f; function Update () { if(Input.GetKey(KeyCode.Space) && !Jumped) { Jumped = true; rigidbody.AddForce(Vector3.up * JumpHeight * Time.deltaTime); } } And here is what I use to prevent jump spamming, its connected with the code above. function OnTriggerStay () { Jumped = false; } What I've also noticed is that upon starting, the GameObject has a Y coords of 0. But, after the jump, it becomes around -0.00002

Viewing all articles
Browse latest Browse all 1264

Trending Articles



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