- Home /
Help with AddForce + dragging objects
Hi!
I'll give you an example of my problem:
I have 2 cubes with rigidbodys. I use AddForce in cube n1 to control it. When I attach cube n2, the extra weight will affect the direction/velocity. This is my objective.
By attaching both of them with a joint I achieved that objective. The problem is that they are not securelly connected, i.e., they "wobble" as if they are connected by a spring.
The effect I wanted is that of a magnet, but with the added effect of the weight dragging of cube n2.
How can it be done?
Answer by spinaljack · May 28, 2010 at 11:22 AM
You can parent the 2nd object to the first and then alter the weight and centre of mass with scripts.
http://unity3d.com/support/documentation/ScriptReference/Rigidbody-centerOfMass.html
After moving the centre of mass you need adjust the position where you apply force because by default, AddForce applies force at the centre of mass.
http://unity3d.com/support/documentation/ScriptReference/Rigidbody.AddForceAtPosition.html
Thanks for the reply.
I tried parenting cube n2 to cube n1 and changing the center of mass of n1's rigidbody, but that didn't do nothing. By parenting, when I add force to n1's rigidbody, both cubes move as one and there is no dragging of n2.
You need to use Add Force at the original position (default is at the centre of mass)
Your answer
Follow this Question
Related Questions
Ball physics help 2 Answers
Realistic methods of propulsion without friction involved 0 Answers
Falling object, change its angle 0 Answers
Position synchronization problem in RPC Network System 0 Answers