Hey guys, quick question…
I have these AI agents… they will move around roads… I cannot use navmesh because those are dynamically created roads… how would you implement their actual movement. Would you get their transforms and then .Translate()?
Or would you have character controllers in them, and use that for movement (we might have many mane agents on a scene).
Any other suggestions are also welcome.
Either way will work; it depends mainly on what sort of animation you want/need.
For example, if these are humans or other legged critters — especially if using Mecanim — then you might want to have the AI just drive the animation controller, and let root motion in the animation cause them to actually move around. This will keep their feet from slipping or gliding, which could be important particularly if they player can see them close up.
But if they’re vehicles, or only viewed from a distance, then that approach is probably more trouble than it’s worth. In that case I would just move the transform around directly, and if you need some animation going on too, just play it and not worry too much about slippage.
I wouldn’t reach for a character controller unless you have some reason to… generally just moving things around directly by their transform is easier. A character controller is only important if you need to interact with physics (for example, bonking into things and causing them to move) but also need to move in a physically unrealistic way (very fast start/stop and turns).
1 Like
Steering Behaviors! And then just move/rotate the thing directly.
Vector3 steering = GetSteering();
velocity = Vector3.ClampMagnitude(velocity + steering, maxSpeed);
// assuming a forward-facing velocity at all times
transform.LookAt(transform.position + velocity);
transform.position += velocity * Time.deltaTime;
1 Like
Hey @JoeStrout , THAT is a nice answer. Thanks a bunch!
@KelsoMRK , have you got any extra material on steering behaviours? a plugin suggestion maybe?