Random directional movements

marty_colwellmarty_colwell Member Posts: 4
edited November -1 in Working with GS (Mac)
I was wondering if anyone can help? I want to show my actors from a top view and have them randomly walk around, and when they bump into a wall or another actor to turn and walk randomly in another direction. I am having problems with bump and turn part.

Comments

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Here's my solution:
    Create a boolean attribute for the actor. 'MoveForward' and set it to be true.

    Rule: if collides with wall
    - Change Attribute 'MoveForward' to false.
    - rotate to angle: angle=random(0,359) Run to Completion, Stops on destination
    - Timer: after 1 second, Change Attribute 'MoveForward' to true.

    Rule: if Attribute Changes: 'MoveForward' is true
    - Move: Direction=0, relative to actor.

    Although this will work better with round collisions since the corners of the box will reactivate the rule when rotating.

    Moved this post to the Game Design Support area.
  • marty_colwellmarty_colwell Member Posts: 4
    Has anyone told you that you are awesome lately.
    This forum is one of the best, straight to the solution, thanks CodeMonkey, works like it should now.
Sign In or Register to comment.