Move back and forth

JamwithnoJamwithno Member Posts: 312
edited November -1 in Working with GS (Mac)
i want the enemy to go back and forth. right now i have it so that when the enemy touches and enemy wall it goes the opposite direction but its not working. Do you guys know of any other ways of doing this?

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi Jamwithno, a couple or more ways to do this; here's a straightforward way:

    Make a game text attribute called Direction, set its value to right.

    Place your Actor enemy wall for the left and right walls. Unlock both, in the left wall's Rules put:
    When Actor receives event overlaps or collides with actor of type Enemy
    Change Attribute game.Direction to right

    and in the other wall:
    When Actor receives event overlaps or collides with actor of type Enemy
    Change Attribute game.Direction to left

    Then in the Enemy (moving) actor's Rules:

    When Attribute game.Direction is right
    Move Direction 0 relative to scene, chosen speed

    When Attribute game.Direction is left
    Move Direction 180 relative to scene, chosen speed

    Hope it helps. :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • JamwithnoJamwithno Member Posts: 312
    It did not work but i think i might be doing it wrong
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    I've just run a test and it's working fine here; couple of things maybe to point out: make sure the 2 wall actors on-screen are unlocked i.e made instances, and make sure that in the Enemy actor's rules, that they are two seperate Rules, not one inside the other.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

Sign In or Register to comment.