A way to tell where inside the collision shape the collision took place?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Skydome

Like I am calling the area entered signal function. For projectile and also melee attacks.
Was wondering if there’s a easy way to tell where the collision shape of the entering area ‘entered’ the collision shape of the character.

What’s the easiest way to find that out? Is there a built in variable for this? Or do I need to do some custom calculation for the variety of different projectile sizes?

:bust_in_silhouette: Reply From: Pomelo

You could go about it in different ways. Lets say the area entering the area of the player is a small one, say of a bullet. Then you can emit the area entered signal from the bullet, and send with it the global position of the bullet. Then if the object recieving the signal also knows the global position of the player, you can calculate the difference, and what you get is the local position of the bullet, relative to the player.

If the area is a bigger one, you can do the same thing of course, but the position you end up getting might not end up being so close to the area of the player.