Enemy pathing

thompsonjm22thompsonjm22 Member Posts: 15
edited March 2012 in Working with GS (Mac)
I'm having some issues with enemy pathing in my platformer right now. Essentially I don't know the proper action or attributes to give the enemy to react the way I want. I would like for my enemy to just move back and forth constantly. I've tried simply "Move To" without success. My other issue is having the enemy start this movement when the player reaches a certain point in the level. Essentially I do not know how to start the enemy's movement when the player reaches this point versus at the very beginning of the scene. Any help would be great!

Comments

  • hotMagichotMagic Member, PRO Posts: 266
    You could make a trigger object to start him (common in all script-heavy shooters), or you could make it more systemic and say, inside his logic, that he attacks when Player is withing X distance.

    You first need to figure out his overall architecture to keep it from getting messy. I would recommend flagging states for him. For example, Patrol means he goes back and forth. Attack means he will stop and chase or shoot. Flee means he will try to run away. This way you can block out the behaviors.

  • thompsonjm22thompsonjm22 Member Posts: 15
    Thanks for the reply hotMagic. My main concern is how to actually code the "patrol" of my enemy. Using different states would be good and i'll try out the first thing you said, but what exactly would I do to make my enemy patrol?
  • MotherHooseMotherHoose Member Posts: 2,456
    @Tynan has back and forth covered:
    http://forums.gamesalad.com/discussion/comment/293623#Comment_293623 video/templates

    @hotMagic good advice!

    @};- MH
  • CloudsClouds Member Posts: 1,599
    I would like for my enemy to just move back and forth constantly


    Constrain the actor's X position to:

    AAA*cos(self.time*BBB)+CCC

    AAA = the distance in pixels he will travel left and right from the centre point, which is CCC . . . and BBB is how fast he will travel.
  • CloudsClouds Member Posts: 1,599
    edited March 2012
    ya but constrains are nasty, you don't want to use to many of those. it can hurt the games performance.

    cheers


    I keep hearing this from quite a few people, that constrains are to be avoided, only recently I've offered 'constraining' and 'spawning' and having two actors instead of one all as ways to address some game design goal, and each time the response seems to be that it's best to avoid all these things as, on some level, they will kill your game's performance. But from my experience this is not the case ????

    By way of a test I just placed 100 actors on an iPad sized layout (I couldn't fit anymore on) - they are all being constrained (with their own individual values) to 512*cos(self.time*100)+512 (so they sweep rapidly from left to right across the iPad's screen) - and they are all being spawned from another actor.

    The iPad had no issue whatsoever with them, the playback kept above 60 fps, and this was on a lowly iPad 1 !

    So that's a scene with a hundred actors being spawned and those one hundred actors all being thrown around the place by a positional constraint quite happily at 60 fps on an iPad 1 ! . . . but in reality most of these questions are from people asking about a single actor (as is the case here) . . . . and as even a hundred constraints on an iPad 1 are no problem I can't see why constrain (and 'spawn') has attracted this label of being 'nasty' and best avoided ?

Sign In or Register to comment.