Categorize hitPositions into 4 sections

Hi yall!

I would like to ask how to group the attack-hitPositions (collision sensor ) into these 4 sections so that my character can define which side is being attacked.
Thank you!~

You could assign a different material to each face of your characters collision box and check the “hitMaterial” property of your touch sensor:

thanks Wendigo, but using many materials for this is abit too inefficient, with python it would be easier to control.

Typically you do not want collision on the mesh skin object, as it would interfere with the collision object (and it has way too mean faces for that purpose).

I suggest you parent invisible sensor objects to the bones. They can be very simple. This way you can detect the hit area.

To make it even simpler (following your sketch) you can have 4 invisible planes around the character as sensor objects to identify what side was attacked. You can parent these planes to the collision object (rather than bones).

You could take the position of the character and the position of the attacker and compare on hit:

attacker.position.x < player.position.x then the attacker is to the left of the player.
attacker.position.z > player.position.z then the attacker is above the player.

Sent from my iPhone using Tapatalk

just localize it,

local = hitPosition-player.worldPosition
local = player.worldorientation.inverted()*local

thanks yall!

yes localizing!! I do the same with collision for ground detection too ( if ground.hitPosition < player.pos - offset ). But i dont know how to invtert the orientation like BluePrintRandom does there o.o. thanks!


I forget to add the ()

local = player.worldorientation.inverted()*local

thanks BPR o.o

how would we divine the sections? O.O

if local.x&gt;0 and abs(local.z)&lt;local.x:
    zone = forward

if local.x&lt;0 and abs(local.z)&lt;local.x:
    zone = back

if local.z&gt;0 and abs(local.z)&gt;local.x:
    zone = up

if local.z&lt;0 and abs(local.z)&gt;local.x:
    zone = down

weee it works perfectly! Thank you (^.^)/

Very nice post, was interested in this too for fps damage zones. Headshot!

local = hitPosition - own.worldPosition
local = own.worldOrientation.inverted()*local
own['ReadOut']=str(local )

# this code assumes that y+ is local forward
# this code assumes Z+ is local up
# this code assumes the actor is 2 units tall

if abs(local.z)&gt;(abs(local.y)+1):
    if local.z&gt;0:
    if local.y&gt;0: