- Home /
Follow script Error NAN?
Error:
transform.position assign attempt for 'pan' is not valid. Input position is { NaN, -4.357757, 3.197214 }. UnityEngine.Transform:set_position(Vector3) keyfollower:Update() (at Assets/keyfollower.js:18)
Code:
#pragma strict
var target : Transform;
var smoothTime = 0.3;
private var mytransform : Transform;
private var velocity : Vector3;
var offsetAmountz : float = 10.00;
var offsetAmounty : float = 10.00;
var offsetAmountx : float = 10.00;
function Start () {
mytransform = transform;
}
function Update () {
mytransform.position.z = Mathf.SmoothDamp( mytransform.position.z,
target.position.z +offsetAmountz,velocity.z, smoothTime);
mytransform.position.y = Mathf.SmoothDamp( mytransform.position.y,
target.position.y +offsetAmounty,velocity.y, smoothTime);
mytransform.position.x = Mathf.SmoothDamp( mytransform.position.x,
target.position.x +offsetAmountx,velocity.x, smoothTime);
}
where is your transform
variable defined? And wehere is your velocity variable declared?
in the inspector using the variables defined in this script.
Try adding in Update():
transform.position = mytransform.position;
OR
don't even use mytransform. Just use transform.position.z, y, x, etc.... Since mytransform is this.transform, there's really no need to store transform in a temp variable.
Changed that but still getting the error seems to be after timescale is = 0 then seeing it to 1 again.
You didn't mention using timeScale, try setting things to Time.deltaTime...
Your answer
Follow this Question
Related Questions
Simple Script getting Errors. 1 Answer
Problems with simple AI script 3 Answers
Error... that I don't understand. 3 Answers
Script errors. I'm Confused 1 Answer
Game Over page score is always 0 1 Answer