Chasing Actor

KCDKCD Member Posts: 24
edited July 2012 in Working with GS (Mac)
I have started creating a really simple 7 on 7 horizontal style football game. I am having trouble getting the defender to chase the player with the ball. What is the best way to get another actor to chase another actor. If i can get the actor(defender) to chase the ball actor rather than the player that would be ideal. But how can I get the actor to chase another actor?

Best Answers

  • master200012master200012 Posts: 372
    Accepted Answer
    Start with a move to position x and y of the ball actor.
    To do this, you have two options.

    Create two real attributes (game). One "ball pos x," one "ball pos y."

    Go into the ball actor and constrain both attributes to their respective positions (i.e. "ball pos x" constrained to "self.position.x."

    Or, in the scene, double click the defender and unlock the lock.
    Then use the "Move To" behavior eezing mentioned and for the x position, go to current scene, find the ball actor, and select its self position x. In a similar manner, do this for the y position.

    Hope this helps!
  • tatiangtatiang Posts: 11,949
    edited July 2012 Accepted Answer
    Here's one way:

  • ericzingelerericzingeler Posts: 334
    Accepted Answer
    Start with a move to position x and y of the ball actor.
    To do this, you have two options.

    Create two real attributes (game). One "ball pos x," one "ball pos y."

    Go into the ball actor and constrain both attributes to their respective positions (i.e. "ball pos x" constrained to "self.position.x."

    Or, in the scene, double click the defender and unlock the lock.
    Then use the "Move To" behavior eezing mentioned and for the x position, go to current scene, find the ball actor, and select its self position x. In a similar manner, do this for the y position.

    Hope this helps!
    Go with option 2. Constraining position will interfere with the physics engine and cause some funky stuff. When changing a position of an actor while using physics, use Move, Move to and accelerate behaviors. If you're really good, you can get away with interpolate in some cases.

Answers

Sign In or Register to comment.