Change Path/Waypoint

ReismehlReismehl Member Posts: 12
edited January 2012 in Working with GS (Mac)
Hi!
I'm working on a game where incoming AI cars need to change direction at an intersection. I saw a Tower Defense video on youtube where the actors changed direction when they overlapped/collided with an invisible waypoint. Anyone know how to do this?
-Erik

Comments

  • MotherHooseMotherHoose Member Posts: 2,456
    for one waypoint just make a small 4x4 actor named dirChange …
    place it in the middle of the intersection point on your image

    and in your prototype for the cars:
    Rule: when
    Event: overlaps or collides with actor dirChange
    --do changes for car's direction that you want.

    when it works well … dirChanger Attributes > Graphics > uncheck the Visible boolean

    @};- MH
  • ReismehlReismehl Member Posts: 12
    Ok, thats what i thought, but its not working properly. The traffic is generated by a spawner, so i've told the Car Actor to move upwards when born.

    Now, after adding the rule you suggested, it only bumps into the dirChange actor, slides on its edge towards the new direction i've set, then continues in the original direction. Obviously, it understands it as "Change direction only while colliding with dirChange, but not permanently."

    Any suggestions?
    Thank you MH for your fast reply.
  • ReismehlReismehl Member Posts: 12
    Ok, I figured it out!

    For the car:
    (when born/spawned) Change attribute: self.motion.linear.y to 100

    Rule: when overlaps or collides with waypoint actor
    Change attribute: self.motion.lenar.x to 100
    and Change attribute: self.motion.lineary to 0

    -Erik

  • MotherHooseMotherHoose Member Posts: 2,456
    edited February 2012
    Aha! you got it! good work! @Ms45333

    often good to:
    Save As… your game to a new sandBox project and play around there until you find what works best, for you.
    then add those behaviors to your original game.

    @};- MH
Sign In or Register to comment.