[solved] detect angle of collision

ichimitch

  • Posts: 52
Basically, I want 'Actor 1' to know from which angle 'Actor 2' collided with it so I can it can push it back at the same angle.  Is there a way to detect the angle from which a collision occurs?

Something like:
When 'Actor 1' hits 'Actor 2' push 'Actor 1' sharply toward degrees 'angle of collision' at force 50

Stencyl provides top, bottom, left and right collision detection but I'm hoping for something with a bit more scope

« Last Edit: May 04, 2018, 12:20:47 pm by ichimitch »

NobodyX

  • *
  • Posts: 1228
Use simple right-angle triangle trigonometry to find the angle. I attached a screenshot of something I have in my game to get the angle between two actors.

I have the "as degrees" block because it converts from radians to degrees just to make things easier on myself but it's not necessary for getting the math right.

ichimitch

  • Posts: 52
Use simple right-angle triangle trigonometry to find the angle. I attached a screenshot of something I have in my game to get the angle between two actors.

I have the "as degrees" block because it converts from radians to degrees just to make things easier on myself but it's not necessary for getting the math right.

hmm thanks. I left school before ever learning trigonometry... Long story :/  Guess I've got some learning to do.
Or not. I just copied your code block and it worked fine. Thanks a bunch.