How do I make a 2d objects move around the map (only one screen no scrolling) randomly just avoiding one obstacle

I need an object to move up, down, left and right on the map. Please help

He said map not app!! Well anyway i can help you

Can you give more context for us to understand?

You can use the pathfinding behavior.

  1. Add a hidden box to fill the area where you want the object to move.
  2. Add pathfinding behavior to object and make sure you uncheck diagonal movement.
  3. Add pathfinding obstacle to the other object you want to avoid.
  4. Use a scene timer and add this event:

Conditions:
-OR-

  • timer > x secs
  • object reached its destination
  • A path has been found (reversed)

Actions:

  • (pathfinding) move to position X pos: box.X() + Random(box.Width()) | Y pos: box.Y() + Random(box.Height())
  • reset timer

When I add pathfinding the object doesn’t move when I press play, I added dragable and that worked.

You need to use the pathfinding "Move to position" action on the object you want to move.

1 Like

Example i pasted in post above
Will make your objects move around either on grid if you set it up
Or freely in 4 directions up down left right

By avoid obstacle i was sure you meant for it to not walk trough it

If you meant they would walk around that one objestcale
Then this example would still work
It would only require 4 additional events for telling objects what to do if they are in collision with obstacle depending on direction from which they came

Can you send a screenshot of your events?
Also make sure you use the action pathfinding “move to position” as MrMen pointed out.