0 votes

Hello there!

Is it possible to apply a radial impulse to all bodies near a global position?
Or do I have to manually calculate impulse vectors one by one for each active body in my scene near to that specific position?

Thanks in advance,

in Engine by (711 points)

1 Answer

0 votes
Best answer

I'm not aware of a built-in function doing that. I think that calculating the vectors for each body inside the "force field" would do the trick. I would query a circular area for bodies in _fixed_process() and apply the force on them.

by (29,042 points)
selected by

Hmm, I don't get the logic behind apply_impulse()...
Are the coordinates local and where is which vector applied?

As the doc says:

void apply_impulse( Vector2 pos, Vector2 impulse )
Apply a positioned impulse (which will be affected by the body mass and shape). This is the equivalent of hitting a billiard ball with a cue: a force that is applied once, and only once.

So the position parameter is local, and the function must be applied once (for example, an explosion, or a billiard ball hit)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.