- Home /
Duplicate Question
Program control not entering onTriggerEnter()
Hi, i am a beginner in Unity3d, and am learning from the Roll-A-Ball tutorial from the unity website. i have come across a problem here, please do help me..
The probelm is where we set the collectables. the scene contains a plane, 4 walls, a sphere as the player, and 10 cubes rotating which act as collectables. the sphere moves and touches this cube, the cube dissapears.
Sphere (player) has a rigidbody attached to it. Cubes do not have rigidbody, but has IsTrigger enabled, so they act as trigger colliders.
My problem is that the sphere moves through the cubes, but the cube is not being deactivated. the sphere just moves through the cubes. i found that the program control is not entering inside the function onTriggerEnter() because the Debug.Log statement at the beginning of the function is not executing. Help me please :)
void onTriggerEnter (Collider other)
{
Debug.Log ("inside onTriggerEnter");
if (other.gameObject.tag == "PickUp")
{
Debug.Log ("function enters inside if");
other.gameObject.SetActive (false);
}
}
This code is attached to the script of the sphere (player).
try OnTriggerEnter ins$$anonymous$$d of onTriggerEnter
Thanks, i got it right; thanks you two.. sorry that i missed such a small mistake.. :D
Answer by geobaby · Jan 04, 2015 at 07:15 PM
OnTriggerEnter() should be used here instead of onTriggerEnter(). Thanks.
Follow this Question
Related Questions
Set Active To Prefab 1 Answer
Strange problem with OnTrigger 0 Answers
Activate / Deactivate objects onTriggerEnter / Exit 2 Answers
SetActive not working. 1 Answer
SetActive(true) does not work on Linux 2 Answers