Constrain one actor to another

bkhoward2001bkhoward2001 Member, PRO Posts: 86

I have a situation where I need to spawn an actor that will travel across the screen; however, I need to spawn another actor which stays right below the first actor....Any ideas how I would do this? thanks.

Comments

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

    There are many tutorials for this if you Google contrain actors gamesalad. But here's the basic method:

    In the spawner actor:
    Constrain attribute game.leaderX to self.Position.X
    Constrain attribute game.leaderY to self.Position.Y
    Spawn actor [follower]

    In the spawned actor:
    Constrain attribute self.Position.X to game.leaderX
    Constrain attribute self.Position.Y to game.leaderY-75

    Notes:
    Game.leaderX and game.leaderY need to be real attributes. Obviously, you can use any value in place of 75. If the spawner actor always has the same Y position, you should use Change Attribute self.Position.Y to game.leaderY-75 instead within the spawned actor. It's best not to have too many constrain behaviors in use.

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

  • BunkerBunker Member, PRO Posts: 36

    you should check out that Guru's vids for beginners - helped me out a lot at first!

    thanks guru!

    https://www.youtube.com/user/dsouza41

  • bkhoward2001bkhoward2001 Member, PRO Posts: 86

    Thank you... Will try.

  • SocksSocks London, UK.Member Posts: 12,822

    @bkhoward2001 said:
    Thank you... Will try.

    This might be overkill, but could be useful.

    http://forums.gamesalad.com/discussion/75220/fast-constrain-linkmachine-v2/p1

Sign In or Register to comment.