Animation facing

What I'm wanting to achieve is when the main actor is right of the zombie that the zombie faces the actor, and when its left of it, it faces the actor. I have both animation sequences for the zombie walking left and right but I don't know how to go about making the zombie know which side the actor is on.

Comments

  • natzuurnatzuur Member Posts: 304
    edited January 2014
    If you track the main actors X through game attributes you can do the following.

    On the Main actor:
    Constrain Game.MainActorX to self.positionX

    On the zombie:
    When Self.PositionX is less than Game.MainActorX
    Play right animation

    When Self.PositionX is greater than Game.MainActorX
    Play left animation

    As a side note if the left and right animation are identical but flipped you can just use the built in self graphcis flip horizontally to flip a single animation to work both ways. This will save memory and can use the same rules as above but with a change attribute.
  • macmashermacmasher Member Posts: 31
  • WingmanappsWingmanapps Member Posts: 458
    edited January 2014
    Or you could simple say

    self.motion.linear.x < 0
    play right animation
    self.motion.linear.x > 0
    play left animation

    Saves you some code and it gives better performance when not using constraints.
  • natzuurnatzuur Member Posts: 304
    Or you could simple say

    self.motion.linear.x < 0
    play right animation
    self.motion.linear.x > 0
    play left animation

    Saves you some code and it gives better performance when not using constraints.
    True but that assumes that the main actors x will never need to be tracked globally for other purposes, and that the zombie will never be stopped but need to continue facing the correct direction.
Sign In or Register to comment.