Forum rules - please read before posting.

Best way to get character to move randomly in 2D

edited November 2023 in Technical Q&A

Hello everyone,
I've been developing a new 2D game with AC (my first 2D, i usually do 3D), and I'm stuck at making my NPC move randomly.

It's an idle game, the scene is made from tilemaps of roads and grass at the moment, and I want the NPCs to move randomly along the road as if they were moving around town. The roads are on its own layer if that helps, its a tilemap.

Previously I used ActionCharMoveRandom (i can't remember if this was a custom script or if it's included with AC lol) but that only let characters move around a marker. Which worked for 3D, but this is 2D and they need to stay on the path only. What can I do?

Thanks so much :)

Comments

  • It's a custom script, yes - available on the AC wiki.

    It should work in 2D, however. Putting aside them not sticking to the path, do they at least to random points in the scene?

    For the restriction of movement to a road in the scene: currently, you'd need to reshape the scene's NavMesh to only fit that path - but that'll prevent pathfinding outside of it.

    I will have a think about how this might be avoided.

  • They do walk randomly still yes. Just gotta make them stick to the path. Thanks Chris:)
  • Try creating the Path as a separate NavMesh, and then using the Scene: Change setting Action both before and after the Character: Move randomly Action to switch to it, then revert back to the deault afterwards.

Sign In or Register to comment.

Howdy, Stranger!

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

Welcome to the official forum for Adventure Creator.