How to make an actor to respond to one side of an actor.

ForteForte Member, PRO Posts: 297
edited November -1 in Working with GS (Mac)
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

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    Hey,

    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!
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I would create two invisible actors and constrain them to either side of the main actor. Use these actors for collisions and not the main actor.
Sign In or Register to comment.