GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Change Path/Waypoint

ReismehlReismehl Posts: 12Member
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 Posts: 2,456Member
    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 Posts: 12Member
    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 Posts: 12Member
    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 Posts: 2,456Member
    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
This discussion has been closed.