enemy chase player only when player is near?

THRSTNTHRSTN Member Posts: 178
edited November -1 in Working with GS (Mac)
Hi guys im trying to figure out the best way to have an actor only follow another actor when they are within a short distance of one another.I know i can get an actor(lets say enemy) an enemy to follow the player from wherever by setting the enemy to move to the players X and Y but how would i go about postponing that for when the player is within a certain range of the enemy and leave the player alone if the player can get a certain distance away?If there's a template out of that or a youtube video i've overlooked that would be awesome but any help is really appreciated.

Thanks
THRSTN

Comments

  • AsymptoteellAsymptoteell Member Posts: 1,362
  • THRSTNTHRSTN Member Posts: 178
    Asymptoteell: thanks ill check that demo out definitely
    and TSB a Video would be awesome.Your videos have helped me out tremendously .I sent you an message a couple of weeks ago about my first game "sideways Pinball" being out and i have a promo code for you. I didn't post any promo codes cause i didn't want guys like that rotstik guy leaving spiteful reviews without actually buying the game.If you want the code shoot me an email at thurstongames@gmail.com Hell Asymptoteell if you want one ill give you one too for answering my post and trying to help out so quickly.
    Thanks guys
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Darren's Platform Template has this built into it. $50 buck I bet he'd tell you how. :)
  • THRSTNTHRSTN Member Posts: 178
    tenrdrmer said:
    Darren's Platform Template has this built into it. $50 buck I bet he'd tell you how. :)

    I really love darrens work and if he's willing to explain for free how he achieves that It would be awesome but I can't afford to spend anymore money on Gamesalad right now. The legacy upgrade was the last of my cash budget so everything from this point on I need to do on 0$
  • UtopianGamesUtopianGames Member Posts: 5,692
    You need a real attribute game.distance or whatever you want to call it.

    In the enemy do:

    2 real attributes StartX and StartY

    Do 2 change attributes: self.StartX to self.position.X same for Y

    Then a constrain on the enemy like, game.distance to magnitude(game.HeroX-self,position.x,game.HeroY-self.positionY)

    Then a rule:

    If game.distance <200 (change 200 to your requirements)

    Move to HeroX, HeroY

    in the otherwise part of the rule do move to StartX, StartY.

    This will attack Hero when hes less than 200 away or go back to his start position if not.

    You also need to make 2 constrains on the Hero's X Y i called them HeroX and HeroY

    Darren.
  • THRSTNTHRSTN Member Posts: 178
    YOU THE MAN!! Another example of the great community we have here,
    thanks Darren
  • JoeMeisterJoeMeister Member Posts: 602
    Yes. Fantastic Darren.
    Thanks. I will be using this somewhere.
  • THRSTNTHRSTN Member Posts: 178
    ok just to make sure im doin this correctly, Ive done everything in the enemies actor but what am i constraining the players X and Y to(i call them playerX and Y theyre real att's)?
  • THRSTNTHRSTN Member Posts: 178
    Not sure what I'm doin wrong cause I did everything Darren said to do in the enemy actor and I created the constrains (hero x and y) for the player xy and constrained them to self but the enemy isnt following he just goes about randomly. I'll try taking a screen shot and posting it in a min. Again any help is very appreciated and TSB I'm looking forward to that video whenever it's out.
  • AsymptoteellAsymptoteell Member Posts: 1,362
    Constrain two attributes (We'll call them X and Y) to the X and Y values of the chased actor. Then make an attribute for the chaser to be constrained to the magnitude(X-self.positionX,Y-self.positionY) In the rule that makes it chase, make it so also, that magnitude attribute needs to be less than however far away you need them to be to chase the chased actor.
  • THRSTNTHRSTN Member Posts: 178
    TSB AGAIN YOU DA MAN!! that is exactly what i was asking and i even see what i was doing wrong with the x and y positioning thanks SOOO much and email me if youd like that promo code

    Thanks everyone
  • scusa83scusa83 Member Posts: 5
    tshirtbooth
    thnx for the tutorial , i fallow all the steps , but the player 2 did not chase player 1

    can you send to me a copy of the platform
    my email
    scusa83(at)gmail dot com

    thanks man
  • scusa83scusa83 Member Posts: 5
    tshirtbooth
    i have sent to you my game

    please can you help me
  • BrackAttackBrackAttack Member Posts: 22
    Wait, tshirtbooth...in your video, why did the enemy just keep going one direction? I expected it to chase the actor around the screen.
  • calvin9403calvin9403 Member Posts: 3,186
    because tshirt did not tell the enemy what to do if the actor escape

    so put an otherwise there and stop the enemy, or do whatever you want

    Calvin
Sign In or Register to comment.