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

How to disable constant force over time? Rocket game

$
0
0
Hello, I have a rocket prefab with a rigidbody and box collider that needs to collect coins (fuel) in order to keep moving up. I would like the rocket to stop moving up (run out of fuel) if you stop collections coins and fall to the ground. My current code after hitting a box trigger is this. function OnTriggerEnter(fuel: Collider){ if(fuel.gameObject.tag == "fuel"){ Debug.Log("We hit a fuel box!"); constantForce.force = Vector3.up * 50; } } I am not sure how to disable the constant Force code above or make it dissipate over time. So I used a force function rigidbody.AddForce (0, 10, 0); This only launched me up into the air exponentially for a brief time but at least I ended up crashing back into the ground. Any help would be appreciated. Thanks!

Viewing all articles
Browse latest Browse all 1264

Trending Articles



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