Bot Paths for Unity

Started by
2 comments, last by parkour 13 years, 4 months ago
I'm currently runnig test on unity 3d for my next game project that takes place in a city. I want it to be as realistic as possible, so i would like citizens walking around. However, I've never had a to make a game that would require bot paths. Can someone please provide me with the Java script or the C# script and the directions on making bot paths. THANKS! :)
Advertisement
IIRC there are implementations of the A* algorithm you can get for Unity which will at least get you pathfinding, but that might be overkill. Search the developer forums.

As for what you asked, it's a lot more complicated then just "give me the code". Creating realistic pedestrian movement is a larger AI problem than that. [smile] You can probably code up some waypoint stuff fairly easily using their character controllers and some tagged objects: bots spawn at spawn points, choose random waypoints and walk to them.

-me
Quote:Original post by parkour
I'm currently runnig test on unity 3d for my next game project that takes place in a city. I want it to be as realistic as possible, so i would like citizens walking around. However, I've never had a to make a game that would require bot paths. Can someone please provide me with the Java script or the C# script and the directions on making bot paths. THANKS! :)

manly men don't ask for scripts. they write them! i can't give you a script,but i can advise you on how to write them.
you could for example make a list of 3D vectors that define the path. and you make the bots walk toward the next destination point,checking if it reached it,and then make it walk to the next one once it has been reached. you can also do it through game objects that only contain a translate component so you can easily construct the path yourself :)
Thanks both of you. I don't know why I didn't think of that before. Waypoints. But anyways, I have another quick question regarding the topic. How can I add a jump code to this.

var speed = 3.0;
var rotateSpeed = 3.0;
var jumpStrength = 5.0;
var gravity = 5.0;

function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis ("Vertical");
controller.SimpleMove(forward * curSpeed);

if(Input.GetButtonDown ("Space"))
{
rigidbody.AddForce (Vector3.up * jumpStrength);
}
}

@script RequireComponent(CharacterController)

This topic is closed to new replies.

Advertisement