Sign in to follow this  

Bot Paths for Unity

This topic is 2572 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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! :)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites

This topic is 2572 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this