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

Countering AddForce by Modifying velocity

$
0
0
I'm currently working on an object grabber mechanic using AddForce to move the grabbed object. However, when the camera too fast, the grabbed object will have a enormous speed and fly in a direction. To counter this, I want to limit the grabbed objects velocity. However, it seems changing its velocity has no impact at all on the object. Here's a simplified Example : grabbedObject.rigidbody.AddForce(force); grabbedObject.rigidbody.velocity = Vector3.zero; What I expect is the second line to set the velocity to zero, but it doesn't. I thought I might be applying a force somewhere else in the code, but when I remove the first line, there is no mouvement at all, which mean that the mouvement is actually all coming from the first line. I thought AddForce just modified the rigidbody's velocity, but why is it still moving then if I put that velocity to 0 ? EDIT : Putting the code on the object that is being grabbed instead of the object that is grabbing seems to work. I'm not sure how yet and would like an alternative.

Viewing all articles
Browse latest Browse all 1264

Trending Articles



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