Hi,
I am moving my object using:
transform.position.z-=0.1;
because it is set to kinematic…
I am trying to make the movement of this object much smoother, searching the WWW I find
So I changed the code from that page to match my preferred z axis, see code below:
var target : Transform;
var smoothTime = 0.3;
var zVelocity = 0.0;
var newPosition : float = Mathf.SmoothDamp(transform.position.z, target.position.z, zVelocity, smoothTime);
transform.position = Vector3(transform.position.x, transform.position.y, newPosition);
I have this in FixedUpdate() …
When running the code I see the exception:
NullReferenceException: Object reference not set to an instance of an object
script+$windtimer$54+$.MoveNext () (at Assets/Standard Assets/Character Controllers/Sources/Scripts/script.js:121)
It is failing on line:
var newPosition : float = Mathf.SmoothDamp(transform.position.z, target.position.z, zVelocity, smoothTime);
Can anyone tell why this is failing?
Or has anyone got some code (or could adapt my code) that might make it easier to smoothly move objects to a new location?
Hmmm, even if I use the unedited code from that Unity reference it give the same error?!
many thanks in advance,
Kim