I’ve got this little character (a 2D Rigidbody with two colliders, basically the same you can find in Unity 2D example) and I would like to add a force field like behavior. Basically, when you press fire, you bump away the objects near you.
Here is a little scheme of what I want to do:
Now, at first I thought to make a rigidbody with a circular collider that activates and quickly grows upon pressing fire (something like a pinball bumper, I guess), but obviously, since my character is also a rigidbody I get all sorts of weirdness. Is there a better way to do it? Can you help me in finding a nice solution?
Thanks!
[Plus, you’ll get a lot of <3 from the little robot in the example]
i’m not sure how appropriate the standard physics are for 2d case. maybe you should constrain your axis. or does this use the 2d physics automatically?
anyway. do a physics.overlapsphere to retrieve all colliders within a certain radius. then apply a force to them. the force can be scaled with the distance so closer objects are pushed harder.
My example already uses the 2d physics. But I guess it should be something like overlapsphere for 2D also, since pretty much all physics function have a 2d counterpart. I’ll look on it, thanks!