Hello All,
I got a console x again, System.NullReferenceException. (sorry still learning Unity).
Anyway the error is
“UnityEngine.Transform:set_localRotation(Quaternion value)”.
“UnityEngine.Transform:set_EulerAngles(Vector3 value)”.
And a reference to my script;(Modified the AICar Script)
- UpdateWithTargetPosition(Vector3 target)
- FixedUpdate()
Script from the UpdateTargetPosition
function UpdateWithTargetPosition (target : Vector3)
{
//calculate target position relative to the target(waypoint)
//coordinate system + x value = target to the right
//+z target is in front
relativeTarget = transform.InverseTransformPoint(target);
//calculate target angle to point towards the target
targetAngle = Mathf.Atan2(relativeTarget.x, relativeTarget.z);
//Atan returns angle in radians, convert to degrees
targetAngle *= Mathf.Rad2Deg;
//Maximum rotation angle
targetAngle = Mathf.Clamp (targetAngle, -steerMaxAngle, steerMaxAngle);
//Apply movement, Muncher is a private var
Muncher.localEulerAngles = Vector3 (0,targetAngle,0);
And the FixedUpdate.
function FixedUpdate()
{
//calculate position should be going towards target;
targetPosition = activeWayPoint.CalculateTargetPosition (transform.position);
//apply force, steer object;
UpdateWithTargetPosition (targetPosition);
}//end FixedUpdate
My object moves but it’s going the other way and my arrow keys now is all messed up. Up/Down became sideways and left/right became forward/reverse.
Appreciate any help I can get.
Thanks,
Ray
PS. I also lost my sight(crosshair) again. ![]()