x


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?

more ▼

asked May 28 '10 at 11:14 AM

Damienthorn gravatar image

Damienthorn
21 1 1 3

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered May 28 '10 at 11:22 AM

spinaljack gravatar image

spinaljack
9.1k 18 31 92

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.

May 28 '10 at 03:08 PM Damienthorn

You need to use Add Force at the original position (default is at the centre of mass)

May 28 '10 at 05:25 PM spinaljack
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1948
x291
x254
x154
x27

asked: May 28 '10 at 11:14 AM

Seen: 1730 times

Last Updated: May 28 '10 at 11:14 AM