1
\$\begingroup\$

I have the object in the image.

The red box is kinematic: when an object hit it , i set kinematic to false, so Unity apply normal physic.

But I would like to apply also a force to the point indicated by the violet cross.

So I'm using Rigidbody.AddForceAtPosition

_rb.AddForceAtPosition (ForceDirection * ForcePower, PointForcePosition.transform.position, ForceType);

PointForcePosition is an empty GameObject child of the red box object, placed where violet cross is pointing.

My question are:

  1. Force Position: can I use that approach (an empty gameObject placed where i want to apply force ) ?
  2. Force Direction: is it corret a Vector3 ( 0 , -1 , 0 ) to indicate a down force
  3. Which ForceMode is the best for my purpose ? Impulse ? Force ?

Thanks

enter image description here

\$\endgroup\$
1
\$\begingroup\$

Since the image is not showing I may not be understanding properly what you're asking but here's my best crack at your questions:

Force Position: can I use that approach (an empty gameObject placed where i want to apply force ) ?

If the purpose of the object is just to store a transformed position there's other options, but your way is fine (especially if you want to tweak its position in the editor).

Force Direction: is it corret a Vector3 ( 0 , -1 , 0 ) to indicate a down force

That depends on what conventions you're using for your coordinates but down being the negative y axis is very common.

Which ForceMode is the best for my purpose ? Impulse ? Force ?

The difference between the two can be confusing but Impulse is effectively 'per frame' and Force is 'per second'. Roughly speaking, Impulse is better when you're applying a force over time (e.g. you're adding the effect of a rocket engine every frame) and Force is better for 'instant' effects (e.g. an explosion). From what you describe Force seems a better fit.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.