hello. i have a dynamic physics object, represented by the gun in this image.
how can i configure the object so that, on keypress:
a bullet shoots out of the gun
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!
Muzan
August 5, 2021, 5:30pm
#2
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?
Gruk
August 5, 2021, 9:25pm
#4
There’s an expression called AngleBetweenPositions(). Use it with the bullet and the gun.
how would i apply this to the scenario i listed?
Muzan
August 8, 2021, 5:21pm
#6
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
MrMen
August 8, 2021, 11:20pm
#8
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