Calculating the angle an item is hit at....

0 favourites
  • 6 posts
From the Asset Store
A fantastic package of 117 high-quality & game-ready sound effects for User Interface, Items, Power-Ups, and more!
  • Not sure if Construct 2 has a built-in method for this, or if there's an easy mathematical approach... if an item is rotated and it's hit by another object, how can I calculate which part of the object is hit? I know I can work out the angle between the two objects, but if the main object (i.e my player ship) is rotated, how can I tell which part is hit (e.g the left wing, the right wing, the cockpit etc)?

  • I too would like to know this. This could be very useful for a fighting game where, depending on the attack, a player would be flung in different directions. Maybe something like an equation to calculate a perpendicular angle using the line between two collision points?

  • Farflamex : Have you considered using multiple Image Points instead ? That way you could say > if Item A hits Image Point LeftWing then ....

    Bscarl88 : Is this useful ?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Is that the calculation to produce a perpendicular line? Im not very good with my funtions yet haha.

  • That calculation states what the angle of movement is from the centre of the screen. (just made it 480x480)

    So if you move to the right it will be 0, move the the top right, it should be -45, bottom right should be 45.

  • I think I'm right in saying that you can calculate it by the collision angle minus your facing angle. I think that works. If the collision hits you at 90 degrees (from below) and you're facing 180 degrees (left), then the hit came at 90 - 180 = -90 (converts to 270), which is your left, which is correct.

    If the collision came from above (270 degrees) and you were facing left (180), then the angle would be 270 - 180 = 90, which is your right.

    That works for my case at least, hope it helps :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)