- Home /
Question by
duscrixbox · May 05, 2019 at 03:39 AM ·
getcomponentontriggerenter
why cant I access the script in ontriggerenter
when I try to initialize the gameobject and script in ontriggerenter nothing happens and when I initialize it in start I get errors saying that the s doesn't belong in current context
private GameObject nm;
public void OnTriggerEnter(Collider other)
{
nm =GameObject.Find("player");
ninjamovement s = nm.GetComponent<ninjamovement>();
s.body.position = (new Vector2(0, 0));
s.Deaths += 1;
}
Comment
Do you use 2D physics component? If so, you must use OnTriggerEnter2D
Your answer
Follow this Question
Related Questions
Updating GUIText 3 Answers
Trouble with OnTriggerEnter and GetComponent 3 Answers
Accessing Variable From Other Gameobject 1 Answer
Need help with get child component script 1 Answer
Check OnTrigger for component 1 Answer