- Home /
addForce (IMPRECISION?) object changing direction after a few frames of launch...
Hi,
I've created a simple plane and a flat cylinder...
When I apply a rigidbody.AddForce to this cylinder it moves nice in the begining sliding alog the plane using the vector direction at initial launch... But then somehow a little later (a few frames) it changes direction? Seems like an unexpected influence or force makes the object move and perturb it's original direction...
Is this some bug or something?
Thanks in advance,
The object is probably just sticking due to friction. Set the material to ice to remove surface friction. If you want to slow down you can use drag ins$$anonymous$$d.
Hi Spinaljack, Thanks for the tip, even though I have played with these material setups, I still got the problem. I'll try again and see if anything changes.
Thx
Answer by Waz · Jul 16, 2010 at 06:01 AM
It will almost certainly be the parameters are you passing changing. If, for example, you are passing transform.forward, then when the cylinder rolls, the "forward" rotates around to face the other way. So then it's not that AddForce is doing anything different, but rather that what you're passing is different.
So pass constant values and the direction will be constant.
Hi Warick, thank you for your reply.
I will check and see if the addforce is being applied to local orientation of the cylinder, as this is what I understood from your answer.
Answer by Caps · Jul 23, 2010 at 03:27 AM
Hi there,
After rebuilding the whole project again I have come to the same "bug". I'm calling this a "bug" because I'm not really sure it is a bug but for sure this rather simple scene shows some awckward behavior.
So, I have tried playing with the rigidbody materials, using ice and all other as suggested...
I have also made sure that the added force only applies during one frame, that is, there are no other forces being applied after the object has been launched!
Still, incredibly, somehow the launched cylinder changes direction after a few frames, it does not move straight...
Could anyone try building this scene (simple plane, flat cylinder like a button, launch this cylinder using rigidbody.AddForce in various directions and check out after a few frames if cylinder maintains it's original launch direction vector before stopping)
Thank you.
Answer by Mike 3 · Jul 23, 2010 at 08:49 AM
Try ticking the box for freeze rotation. With the same setup you described, the cylinder rolls off in some random direction without it ticked, with it on it slid in the correct direction
Answer by Caps · Jul 27, 2010 at 02:36 PM
Hi Mike
Thank you for your answer, although that does not solve the problem.
After adding a trail renderer and an orthographic top cam, I could see that there really is something wrong with this issue. The object does curve regardless of material, mass and freeze rotation settings and the worst part is that it seems to "snap" to one of the world axis like x or z...
You can check out the video posted that shows this problem.
http://forum.unity3d.com/viewtopic.php?t=59137&highlight=addforce
If anyone would know what is happening or could help, please do.
Thank you,
Answer by Wolfram · Aug 07, 2010 at 01:07 PM
Set the BounceThreshold in Edit->Project Settings->Physics to a smaller value.
Your answer
Follow this Question
Related Questions
Problems changing terrain editing tool. 3 Answers
add force in camera direction 1 Answer
Raycast Hit Question 1 Answer
AddForce problem 2d 1 Answer
Separating direction from force w/ rigidbody.AddForce 1 Answer