Avoiding Objects

I want an actor to follow another but the second actor collides with walls so I want to know how to make an actor avoid objects like walls.

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    What you want is artificial intelligence. What you need is to come up with a plan for how that artificial intelligence would work (e.g. "When the actor collides with a wall, wait one second, turn in a random direction, and then move in that direction") and then we can help you figure out how to code the AI.

    Think about how you would avoid a wall in real life. You might use your eyes to see it from afar, or your hands to touch is from nearby. One idea is to constrain an actor in front of the other actor and have a collide rule on the front actor that changes a boolean so that the trailing actor knows about the collision. Another is to use magnitude to figure out how far you are from a wall... that approach is probably more complex because of needing to know which wall you are near.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • villewantedvillewanted Member, PRO Posts: 66
    Thank you very much! I will try to implement it
Sign In or Register to comment.