- Home /
Question by
CB-TV · Feb 01, 2014 at 05:31 PM ·
gameobjecttransformparentscript errorconsole errors
'parent' is not a member of 'Object'.
I'm get these errors: 'parent' is not a member of 'Object'. 'localPosition' is not a member of 'Object'.
I guess it's something to do with Unity not knowing what the variable object is. When I put : gameObject; after I declared the variable object the errors went away but it didn't know what gameObject was. What do I do to get these error away and why are they here?
var PickedUp;
var object;
function Start ()
{
object = gameObject.transform;
}
function PickUpObject ()
{
PickedUp = true;
object.parent = Camera.main.transform;
object.localPosition = Vector3.forward * 5;
rigidbody.useGravity = false;
rigidbody.isKinematic = true;
}
Comment
Best Answer
Answer by KellyThomas · Feb 01, 2014 at 05:36 PM
You will find things are much easier when you declare you variables with an explicit type
var object: Transform;