Bots appearing algorithm

Started by
1 comment, last by DracoLacertae 12 years, 3 months ago
Hi all!

I need real algorithm of bot's appearing & moving.

Bots (there're car bots), must appear and move around the player in some circle. In whole world there're routes for bot moving. If bot move out circle it must dissapear.


Any ideas, links..
Thanks.
Advertisement
You're going to have to elaborate a bit on this. Give details on the game, what you expect to see and happen, etc.

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

I think I know what he wants: something like in the GTA games where there is the illusion of random cars driving all over the city. Actually, only the cars within a certain radius of the player exists. My 'pet' project game is an asteroids clone in open space, and required the same illusion. Basically there's a few parameters, and a few rules:

(For me the 'object' is an asteroid. For you its cars.)

Parameters:

object space radius : maximum distance from player to track these objects
minimum object count : minimum number of objects to have within the object space radius
maximum object count : most number of objects to have within the object space radius


Rules:

Initial state: When the game starts, for some random number R between minimum and maximum object count, place R objects in random locations within the object space radius. Each object is moving in a random direction. In free space, this was easy, for you, you'll have to restrict each car to a particular road and have it moving in a random direction along that road.

Object leave rule: When updating an object's position, if it falls outside of the object space radius, delete it. If this results in object count going below the minimum, immediately execute the object create rule.

Object create rule: Every so often (random timer, etc) if the number of objects within the object space radius is less than the maximum, create an object on a random point along the object space radius circle (for me in space it was a sphere).

A few notes:

-If you literally implement the Object leave rule, the player could be looking at an object while moving away from it backwards. When the object pops out of existance, if the player move towards where it was, its gone. Instead, have a Object render distance that is somewhat smaller then the object space radius. That way if an object disappears to the player for a moment, it might still exist when he goes back towards it.

- If the player is not moving (or is a moving significantly slower than these objects are), then when creating an object, its best to create one that is moving towards the player. This is because any object moving away from the player will leave the radius in the next frame. (When the player is moving faster than the average speed of these objects, its best to create a mix of objects moving towards and away from the player, because the player can easily overtake the newly created objects and keep them in the radius)

Hope this helps!

Oh, and please let the random cars occasionally crash into each other! I want angry road-raged drivers in your virtual city :) The NPC drivers in Vice City were too nice to each other.

This topic is closed to new replies.

Advertisement