# Help with "3rd person fighting game" grappling

I want a grappling system similar to Tekken, in which different grapples(animations) are performed on different directions. For example, a player is facing the opponent face to face, and he performs the grapple move, it would be different when he is facing the opponent’s back using the same buttons for the grapple move and even in tekken if the player faces the opponent from the side the grapple will be different too.
So overall I’ve seen three animations performed using the same buttons depending upon the side the player is facing the opponent. But I’ve no idea how to achieve this. Please give me some suggestions.

This is also a thing for AI: is someone in front of me? To my left? Are they walking more towards or away from me? So might help to look there.

One useful trick is to put them in your local coords. `Vector3 localSheila = mary.inverseTransformPosition(sheila.position);` will tell you where Sheila is in relation to Mary. In other words, it give you new numbers for Sheila, based as if +Z was the way Mary is facing. If z is positive, Sheila’s in front of you. If x is positive, she’s to your right. Local coordinate systems is a bread&butter lookup-able math concept (not just games,) if it seems useful and you want to visualize it better.

For relative facing, `float F = Vector3.Angle(Mary.forward, Sheila.forward)` can help. If we are “facing” each other, F will be 180 (the way I’m looking is 180 degrees from the way you’re looking.) Of course, we might also be back-to-back, so you also have to check position. F is always positive – if Mary is looking at Sheila’s left OR right side, F will be 90.

You might also go with the relative angle: `float A = Vector3.Angle(Mary.position, Sheila.position);`. Note how position compares where we are, and forward compares the way we’re looking. So, if A is close to 0, Mary is facing Sheila and can attack. Same “no +/-” problem. If A is 10, Sheila is 10 degrees to your left OR right.

Then, if you want to fix how Angle won’t tell you left vs. right, you can use `localSheilaF = mary.inverseTransformDirection(sheila.forward);`. That will give you Sheila’s “look direction” the way Mary sees it. If X is positive, Sheila is looking more to Mary’s left.