# How to solve error transform.position assign attempt for 'Car' is not valid. Input position is { NaN, NaN, NaN }.

In my game i have a car following a waypoint system, everyting seems to work perfectly but after a random amount of time my AI car stops moving and gives me the error transform.position assign attempt for ‘Car’ is not valid. Input position is { NaN, NaN, NaN }.
This is the code i am using.
Any help in solving my problem would be much appreciated.

``````var path : Array;
var pathGroup : Transform;
var maxSteer : float = 15.0;
var wheelFL : WheelCollider;
var wheelFR : WheelCollider;
var wheelRL : WheelCollider;
var wheelRR : WheelCollider;
var currentPathObj : int;
var direction : float;
var distancefrompath :float = 5.0;
var maxTorque : float = 50.0;
var currentSpeed : float;
var topSpeed : float = 50.0;
var decellerationSpeed : float = 10.0;
var steerVector : Vector3;

function Start()
{
rigidbody.centerOfMass.y = -3.5;
GetPath();
}

function GetPath()
{
var path_objs : Array = pathGroup.GetComponentsInChildren(Transform);
path = new Array();

for (var path_obj : Transform in path_objs)
{
if(path_obj != pathGroup)
{
path[path.length] = path_obj;
}
}
Debug.Log(path.length);
}
function Update()
{
GetSteer();
Move();
}

function GetSteer()
{
steerVector = transform.InverseTransformPoint(Vector3(path[currentPathObj].position.x,transform.position.y,transform.position.z));
var newSteer : float = maxSteer * (steerVector.x / steerVector.magnitude);
direction = steerVector.x / steerVector.magnitude;
wheelFL.steerAngle = newSteer;
wheelFR.steerAngle = newSteer;
if (steerVector.magnitude <= distancefrompath)
{
currentPathObj++;

if (currentPathObj >= path.length)
{
currentPathObj = 0;
}
}
}
function Move()
{
currentSpeed = Mathf.Round(currentSpeed);
if(currentSpeed <= topSpeed)
{
wheelRL.motorTorque = maxTorque;
wheelRR.motorTorque = maxTorque;
wheelRL.brakeTorque = 0;
wheelRR.brakeTorque = 0;
}
else
{
wheelRL.motorTorque = 0;
wheelRR.motorTorque = 0;
wheelRL.brakeTorque = decellerationSpeed;
wheelRR.brakeTorque = decellerationSpeed;
}
}
``````

Perhaps you are getting divide by zero error in the two lines

``````var newSteer : float = maxSteer * (steerVector.x / steerVector.magnitude);
direction = steerVector.x / steerVector.magnitude;
``````

Do you get the error when your character has reached the current path location? i.e the point at which InverseTransformPoint chucks in a load of zeros?