Question by
TheGoldenSaiyan · Nov 28, 2015 at 11:00 AM ·
not working
In my script, "target" is apparently not in context. can anyone help fix it?
public class PickUp : MonoBehaviour
{
void OnMouseDown()
{
this.transform.position = target.position;
this.transform.parent = GameObject.Find("FPSController").transform;
this.transform.parent = GameObject.Find("FirstPersonCharacter").transform;
}
void OnMouseUp()
{
this.transform.parent = GameObject.Find("FPSController").transform;
this.transform.parent = null;
}
}
Comment
Answer by tanoshimi · Nov 28, 2015 at 12:26 PM
public class PickUp : MonoBehaviour
{
public Transform target;
void OnMouseDown()
{
this.transform.position = target.position;
this.transform.parent = GameObject.Find("FPSController").transform;
this.transform.parent = GameObject.Find("FirstPersonCharacter").transform;
}
void OnMouseUp()
{
this.transform.parent = GameObject.Find("FPSController").transform;
this.transform.parent = null;
}
}
Your answer
Follow this Question
Related Questions
StartCoroutine in Collision unwork 1 Answer
Colliding doesnt work 1 Answer
how to get mono develop working? 0 Answers
Mac Unity won't run, no error message 0 Answers