Physics Impulse off of a projectile

hello. i have a dynamic physics object, represented by the gun in this image.


how can i configure the object so that, on keypress:

  1. a bullet shoots out of the gun
  2. the gun receives an impulse in the opposite direction that the bullet fired–in the case of the image, the gun would travel up and to the right.

in the instance below, the bullet is firing to the bottom right, and the gun flies up to the top left:

left me know if i can clarify anything. thanks in advance!

If gun shoot key is pressed
Add a force to gun something like this with physics behaviour

How do I make it so that the added force makes the gun travel in the opposite direction of the bullet?

There’s an expression called AngleBetweenPositions(). Use it with the bullet and the gun.

how would i apply this to the scenario i listed?

If bullet is being shot, add a force to gun towards -gun.angle()

1 Like

thanks for the response. why does the gun object always travel to the top left regardless of where the gun is positioned? excuse the shoddy sprites, i made them for the example lol

all my events:

i couldn’t capture the video on my pc, so here’s some pictures explaining what i mean

Possibly because direction is always positive?

Why are you applying a force with direction as co-ordinates? If the bullet is heading at gun.angle()+180, then apply a force to the gun at gun.angle()

1 Like

this ended up being the solution. thanks!

1 Like