I have a simple script where my ship is supposed to align itself smoothly to be parallel to track’s surface and my problem is this error:
transform.localEulerAngles assign attempt for 'Pl_Carpet' is not valid. Input localEulerAngles is { NaN, 0.000000, -0.000000 }.
UnityEngine.Transform:set_localEulerAngles(Vector3)
FullShipController:ShipTurning() (at Assets/Scripts/Ship Controls/FullShipController.js:155)
FullShipController:Update() (at Assets/Scripts/Ship Controls/FullShipController.js:85)
I totally don’t have idea why is this happening, tried many things but just keeps happening… someone knows why is this happening?
Here’s my code: (‘var AxisRotation’ is a float)
function ShipTurning (){
var HorizAxisInput = Input.GetAxis("Horizontal");
var AxisRotation = PlayerShipAxis.GetComponent("ShipAxis").ShipRotation;
if (ShipOnMagStrip == true){transform.Rotate(0, HorizAxisInput * ShipHandling * Time.deltaTime, 0);}
else {transform.Rotate(0, HorizAxisInput * ShipHandling * Time.deltaTime, 0, Space.World);}
var CurrentAngle = transform.localEulerAngles;
HorizBankVar = Mathf.Lerp(HorizBankVar, HorizAxisInput, Time.deltaTime * 2);
if (ShipOnMagStrip == false && PerformBarrelRoll == false){
CurrentAngle.z = -HorizBankVar * 50;
CurrentAngle.x = (((AxisRotation / -AxisRotation) * (CurrentAngle.x - AxisRotation))) * Time.deltaTime;
transform.localEulerAngles = CurrentAngle; (error message points here)
}
}