Alright guys, so Im playing with the (not so now) new 2d feature in unity finally, and making a little game. Now, a crucial feature of this game is wandering AI, and thats about the only thing I havent figured out. Its sidescroller with no jumping, so its just left and right. But I cant think of a way to…
1). Have AI randomly wander around the small map, changing direction at different times
2). Avoiding obstacles such as the end of the map
3). Flipping sprites when it moves in a different direction, so for example when it moves left its facing left
(I have already done that with my movement script, it uses
)
So, it may be a big ask, Im not entirely sure because AI is new to me (used to making multiplayer games). Movement can just be the very simple translations, no need for fancy rigibody physics based movement.
You could create a timer in update that resets itself in a random time. Each time it resets itself you could fire off a random int that reps ( ie ) eight different directions. As an all to set directions you could set random values in a Vector2.
This is fantastic! I just had a few issues with it, I guess they’d be an easy fix
1). Is there anyway to make this just left and right, because at the moment even with random direction, it seems to be quite bumpy, so just a way to make it smoothly go in just the left and right direction
2). Is there a way to make it avoid the 2d wall colliders, and not just walk into them
3). Is there a way to make them randomly stop for a few seconds, then go off again
Ever so sorry if Im asking a lot, because again this script is almost perfect for me, just need to sort out these small issues.