How do I make my enemies move towards my Hero's position?

Hello everyone, I'm hoping that somebody out there can assist me with a problem I am having in my game. I am designing an "enemy wave" style game, and I want my enemies to spawn in specific locations and then accelerate towards my Hero when the round starts. I am new to GameSalad, but have a pretty okay understanding of how things work from prior UDK use, so I shouldn't be to lost if somebody could please assist me. I have tried to set attributes for the Hero's X and Y positions, followed by a Move To "player X" and "player Y" behavior on the enemy actor, but that didn't do the trick. If anyone can help me solve my problem I'd greatly appreciate it!

Comments

  • guillefaceguilleface Member Posts: 1,014
    create 2 game global attributes,hero-x and hero-y
    on your hero,
    constrain "hero-x" to self.position-x
    constrain "hero-y" to self.position-y
    on your enemies after they spawn add
    move to x="hero-x"
    move to y="hero-y"
    this should work.
  • williamtyleradairwilliamtyleradair Member Posts: 12
    Thanks very much guilleface! I'll try this out asap and let you know how it goes.
  • williamtyleradairwilliamtyleradair Member Posts: 12
    edited April 2013
    Hey guilleface, which attribute type would I use when making the hero-x and hero-y globals? Would they be integers?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Generally, it's best to use real attributes with positions because that's how GameSalad keeps track of them (e.g. you can drag an actor to self.position.X=412.592). If you use integers, it just means that GS will round the values to whole numbers. I recommend using real because of that.

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

  • williamtyleradairwilliamtyleradair Member Posts: 12
    I appreciate your recommendation and thorough response tatiang. I am new to GS but loving it! Have a great day.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You're welcome. If you're new, you may find the Cookbook and other resources mentioned here helpful: http://tinyurl.com/ForumsFAQs. There are also great tutorials and templates available at GSHelper.com and DeepBlueApps.com.

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

Sign In or Register to comment.