Center an actor onto the center of a separate actor

I'm a greenhorn-noob, and I've been working on a problem for the past 2 weeks because I wanted to figure it out on my own, but most importantly. I didn't want to bother anyone. But it's time to give in and ask for help. I have checked the community forum, knowledge base, and google, and haven't been able to find an answer. I'm trying to center 1 actor onto the center of a 2nd actor. I would really appreciate any suggestions. Thanks a lot !!

Best Answer

  • tatiangtatiang Posts: 11,949
    edited October 2015 Accepted Answer

    Make two real game attributes called game.leaderX and game.leaderY (or anything else you prefer to call them). In the leader actor, have two behaviors at the top of the rule list but not inside of any rules:

    Constrain Attribute game.leaderX to self.Position.X
    Constrain Attribute game.leaderY to self.Position.Y

    In the follower actor, have two behaviors at the top of the rule list but not inside of any rules:

    Constrain Attribute self.Position.X to game.leaderX
    Constrain Attribute self.Position.Y to game.leaderY

    If you want the follower actor to move to the center of the leader actor but not continue following it, replace the follower's behaviors with Change Attribute behaviors.

    Let me know if you have any questions about this.

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

Answers

Sign In or Register to comment.