- Home /
Duplicate Question - http://answers.unity3d.com/questions/topics/bce0019.html
object is not a member of 'UnityEngine.Component'.
From what I can tell nothing is wrong....
Assets/Scripts/Pickup.js(7,96): BCE0019: 'hand' is not a member of 'UnityEngine.Component'.
#pragma strict
function OnTriggerEnter (other : Collider){
if(other.gameObject.tag == ("Player")){
other.gameObject.SendMessage ("ItemPickup", transform.parent.gameObject);
transform.parent.gameObject.rigidbody.isKinematic = true;
transform.parent.gameObject.transform.parent = other.GetComponent("Inventory").hand.transform;
transform.parent.gameObject.transform.position = other.GetComponent("Inventory").hand.transform.position;
transform.parent.gameObject.transform.active = false;
}
}
Try changing the variable name to something other than transform, as it may be trying to find a transform of an object that is null.
If that doesn't work, have you tried transform.gameObject.parent
Ins$$anonymous$$d of putting parent first. That is as much I can help, without knowing more code.
Answer by tanoshimi · Nov 08, 2014 at 07:55 PM
GetComponent is returning... a component. Unity components don't have hands.
You want an Inventory, and the easiest way to get that is to use the generic version of GetComponent:
other.GetComponent.<Inventory>().hand.transform
etc.
transform.parent.gameObject.transform.parent = other.GetComponent("Inventory").hand.transform;
transform.parent.gameObject.transform.position = other.GetComponent("Inventory").hand.transform.position;
Should be:
transform.parent.gameObject.transform.parent = other.GetComponent.<Inventory>().hand.transform;
transform.parent.gameObject.transform.position = other.GetComponent.<Inventory>().hand.transform.position;
Follow this Question
Related Questions
BCE0019: 'vertices' is not a member of 'Object'. 1 Answer
UnityEngine.GameObject Error 1 Answer
Is it the same javascript 1 Answer
javascript equivalent of Action? 0 Answers
move the ball randomly in unity android 2 Answers