Original Post
🔒 Locked
Wander
Advertisement
...Uh, yeah..
Don''t make every single movement random, that will just cause the character to "shake around", as you call it. Instead, set random waypoints for the unit to move to. Every time the unit moves to the waypoint, set another one at a random location.
swift URL | browse my bookmarks [server may not always be on]
Sensimed | Info/download
Don''t make every single movement random, that will just cause the character to "shake around", as you call it. Instead, set random waypoints for the unit to move to. Every time the unit moves to the waypoint, set another one at a random location.
swift URL | browse my bookmarks [server may not always be on]
Sensimed | Info/download
direction = rand()%8; //varies according to game type
time = (rand()%50000)+1000; //numbers vary greatly
while(--time)
{
move(direction);
}
If barbie is so popular, why do you have to buy her friends?
time = (rand()%50000)+1000; //numbers vary greatly
while(--time)
{
move(direction);
}
If barbie is so popular, why do you have to buy her friends?
My MUD uses a simple depth-first ''search'' for wandering. Pick a direction, then pick a direction from wherever that last one would take you, and repeat until you''ve moved far enough from the original position. Then you have a path for the character to follow.
For a game with more logical topology (eg. RPG/RTS/FPS/etc), you may want to pick a position on the map/level at random - perhaps within a certain maximum distance of the current position - and plot a path (using breadth-first search, or A*, etc) there.
[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]
For a game with more logical topology (eg. RPG/RTS/FPS/etc), you may want to pick a position on the map/level at random - perhaps within a certain maximum distance of the current position - and plot a path (using breadth-first search, or A*, etc) there.
[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement