Question by
KelynC · Apr 29, 2016 at 06:25 AM ·
javascriptnullreferenceexception
NullReferenceException on second line but not first?
Hi, I'm running this code:
function Update () { if (Active){ transform.rotation = Quaternion.Slerp(transform.rotation, Target.rotation, Time.deltaTime * Smooth); transform.location = Vector3.Slerp(transform.location, Target.location, Time.deltaTime * Smooth); } }
I get a NullReferenceException on the second line (transform.location...) but not the first (transform.rotation...). Why? Why am I getting an exception at all, the lines are basically identical?
Also, this site is crap. Third time I'm retyping this post trying to get it to submit.
Comment
Best Answer
Answer by Whiteleaf · Apr 29, 2016 at 07:34 AM
You want to use transform.position instead. That's all. :)
...unless there's actually a transform.location.