How to make an actor to respond to one side of an actor.
Forte
Member, PRO Posts: 297
hello, how do i make an actor only react to a behavior when colliding with another actor, but only of one certain side of the actor?
e.g. actor has sword, actor comes along, other actor swings sword when actor is in front. But at that moment another actor walks along and collides with the actor from behind, they both die. only the person a the front should die.
that should help you on what i want to do.
Cheers, Dragokillz
e.g. actor has sword, actor comes along, other actor swings sword when actor is in front. But at that moment another actor walks along and collides with the actor from behind, they both die. only the person a the front should die.
that should help you on what i want to do.
Cheers, Dragokillz
Comments
Check if the enemies are on the correct side by using the self.Position.X and Self.Postion.Y attributes...
I would also set up two global game attributes (real) called PlayerX and PlayerY.
In the player actor, constrain game.PlayerX and game.PlayerY to self.PositionX and self.PositionY.
So, in the enemy actor:
Kill me if:
When the sword is visible
and
I am colliding with the player
and
When the game.PlayerX is < self.PositionX
and
When the game.PlayerY is > self.PositionY
Adjust the ">" and "<" to coordinate to the side where the sword is.
You could also track 4 more game attributes (booleans) called:
PlayerFacingRight
PlayerFacingLeft
PlayerFacingUp
PlayerFacingDown
And use those in addition to the previous rules.
Does that make sense?
Hope this helps!