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

rigidBody.addforce doens't work like i want it to

$
0
0
My game is a 3d platformer. I have some pressureplates in my scene, and when u step on them u get like a "forcejump". U get fired up in the air like when u jump. The problem is when i step on one of them, and afterwards land on one of the other plates, i fly much further up. How can i make it so i only jump the same height everytime? Here is my script, its pretty basic so i dont think i have to say anything more than the "jump" tag is the plates. #pragma strict var speed : int = 10; function Start () { } function Update () { if(Input.GetKey("a")) { transform.Translate(Vector3(-speed,0,0) * Time.deltaTime); } if(Input.GetKey("s")) { transform.Translate(Vector3(speed,0,0) * Time.deltaTime); } } function OnTriggerEnter (other : Collider) { if(other.gameObject.tag == "jump") { print("JUMP"); GetComponent.().AddForce(Vector3.up * 500); } }

Viewing all articles
Browse latest Browse all 1264

Trending Articles



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