how to follow curved path?

If I want an object to travel from point A to point B, but also want the object to start from facing its own forward direction to facing aligned with a direction B.forward, then what is the best way to implement this? So far I calculate a bezier curve with my own script, but I cannot find the length of the curve which I need so that the object can travel at a constant speed. Some solutions talk about evaluating the curve numerically but this seems inefficient for many moving objects.

Example this would be a way a car moves from point A to point B.

If you really want to follow some curve, maybe this whydoidoit’s article may help you. On the other hand, if you just want to move in the object’s forward direction while turning gradually to the target, do exactly this: calculate each frame the target direction, Slerp a little to it and then move the object in its current forward direction:

public var speed: float = 5.0; // linear speed in m/s
public var turnSpeed: float = 1.5; // rotation speed control

var target: Vector3; // assign the target position to this variable

function Update(){
  // update direction each frame:
  var dir: Vector3 = target - transform.position;
  // calculate desired rotation:
  var rot: Quaternion = Quaternion.LookRotation(dir);
  // Slerp to it over time:
  transform.rotation = Quaternion.Slerp(transform.rotation, rot, turnSpeed * Time.deltaTime);
  // move in the current forward direction at specified speed:
  transform.Translate(Vector3(0, 0, speed * Time.deltaTime));
}

iTween does what you want I believe (available for free in the asset store).

Edit… apparently Super Splines Pro is very good be sure to look at that as well.

note that mathematically, points on bezier curves over equal T are approximately equidistant only.

But it is utterly inconceivable that it would matter in a video game.

What you normally do is simply look at (literally use “LookAt” in unity) a number of points ahead (say, 4 points ahead – try different values – 3, 2, 5 etc – for the best look).

This is precisely how any race game you’ve ever played works.

Again it’s utterly impossible to know what you’re trying to do … unless you tell us, even in the most general terms. What is the domain of speed etc? (Is this a 2D arcade game? a parking simulator? a race game? flight game in 3D? or?)

FWIW, I’ve begun using Curvy (http://www.fluffyunderware.com/pages/unity-plugins/curvy.php), and if your application depends heavily on splines, I would say it’s worth the money. No relation to the developer, just a user.