Moving an Enemy

peachpellenpeachpellen Member Posts: 977
edited November -1 in Working with GS (Mac)
I have a platform with a ghost on it - I'd like this ghost to move left and right.

Can someone please tell me how to do it? I'm sure I've done this previously but I can't seem to make it work today >.<'

Thank you!

Peach :)

Comments

  • design219design219 Member Posts: 2,273
    See if this does what you need: http://gamesalad.com/wiki/how_tos:gsc_pacing

    _________________________________

    HOLY NOSE JOB!: Nesen Probe: Is this the single most unappealing game in the history of GameSalad? I can't seem to give it away! Anywhere. But if anyone want's to try it out, codes are still available! http://gamesalad.com/forums/topic.php?id=8097
  • reddotincreddotinc Member Posts: 653
    Hmm let me think:

    Say you have a platform from x coordinates 100 and 200

    Attr - enemyMoveLeft

    Rule
    ----------------------------------------------------

    if enemyMoveLeft = 1

    then

    Move to x = 100
    Animation

    otherwise

    Move to x = 200
    Animation
    ----------------------------------------------------

    Rule
    ----------------------------------------------------

    if position.x >= 200

    then

    change attr enemyMoveLeft = 1
    ----------------------------------------------------

    Rule
    ----------------------------------------------------

    if position.x <= 100

    then

    change attr enemyMoveLeft = 0
    ----------------------------------------------------

    That might not be the best way but that's how I know should work.

    Hope that helps.

    // Red Dot Inc
  • POMPOM Member Posts: 2,599
    do you want it to move independently?
    or with a trigger ?!

    if independently -
    constrain self.positionX to sin(self.time * speed ) * "pixels to move" + initialX

    "speed" - the higher the value the faster it moves .
    "pixels to move" - if you put 30 it moves 30 pixels to left and 30 to right , so total of 60 pixels
    "initialX" - the center of the movement ( dont use "self.position" here )
  • peachpellenpeachpellen Member Posts: 977
    Thanks all - will look at those now and work out which one will work best for me. :)
  • peachpellenpeachpellen Member Posts: 977
    Got it working; cheers again all :)
Sign In or Register to comment.