How to make an actor follow another actor

SoAGAMESSoAGAMES Member Posts: 81
edited January 2016 in Working with GS (Mac)

Hello guys please help I try to make an actor follow my actor but always this to a distance of the and that is the same .

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Please use descriptive thread titles instead of "Please help ?"

    I've changed this one for you.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • imjustmikeimjustmike Member Posts: 450

    You could use a combination of magnitude and accelerate towards.

    Create global real attribute called hero_x and hero_y then constrain them to the x and y position of your first actor (the hero).

    Then in your second actor, the follower, create a real self attribute called distance.
    Constrain that self attribute with magnitude to work out the distance from the other actor.

    Then create a rule that if self.distance > 100, accelerate to the hero_x and hero_y, else change attribute x velocity and y velocity to 0

    What this will do is tell the follower to move the the hero's location but only when it's more than 100px away, otherwise, the actors will always end up on top of each other.

Sign In or Register to comment.