So, this is somewhat of a loaded question and I will try to do my best to explain it.
I am creating a vehicle AI system, and the vehicle has a Steer(x) function. X ranges from -1(steer left) to 1(steer right).
I’m trying to find the value that I need to pass to that function to steer my vehicle accordingly to a target, in this case the next checkpoint.
An example: Imagine a vehicle to the right of a checkpoint, this function should return something like -0.2 to steer the vehicle back towards the checkpoint.
This is what i’ve tried:
Vector3 relativePos = path.corners[0] - transform.position;
Quaternion targetRotation = Quaternion.LookRotation(relativePos);
float y = transform.eulerAngles.y;
float DeltaAngle = Mathf.DeltaAngle(y, targetRotation.eulerAngles.y);
Debug.Log(DeltaAngle / 360f);
and
float dot = Vector3.Dot(transform.forward.normalized, (_Target.position - transform.position).normalized);
However it doesn’t produce the correct steering value.
Any help would be appreciated.