0
\$\begingroup\$

I see that, in the Unity editor, there are only Effector2D components, but no Effector components. Are there other components that can be used with the 3D physics engine, that function like effectors? Or should I write my own custom components for this?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

The Unity 2d and 3d physics engines are completely separated from each other and work in very different ways. So you can not expect to see every feature being mirrored 1 to 1 between 2d and 3d. The effectors happen to be among the features exclusive to the 2d engine.

But if you want to simulate them, then that's often not difficult to do.

Create a game object with a collider set to "Is Trigger" enabled. The shape and size of the collider represent the area of effect. Then add a MonoBehaviour which implements OnTriggerStay(Collider other) to apply the physics forces to the Rigidbody of anything within the trigger.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Sometimes I'll use OnTriggerEnter and Exit to add/remove objects from a list, then in FixedUpdate apply my forces to the whole list. I don't know whether this is a net efficiency win or not, but it can be helpful if the effector needs additional context to calculate the right response, rather than re-evaluating that context repeatedly in every callback. \$\endgroup\$
    – DMGregory
    Commented May 21, 2020 at 17:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .