I'm using a OnTriggerEnter, but for some reasons.. It doesn't seem to detect the collision.
Used the method on other scripts, all work, but not for this particular one.
Here is the snippet of code
Saw it was because I missed that I needed the RigidBody. Is there a way to get a similar result as a OnTriggerEnter without a RigidBody?
I assume you are asking, "Why is this collision not being detected?" rather than something else about the undetected collision.
As per equalsequals' comment, it is possible that the collision is happening, but that your if statement or however you are identifying that the collision is happening is failing rather than the collision not being detected. Using Debug.Log and/or print statements would help you identify which is the case.
The docs on OnTriggerEnter clearly state:
Do you have a Rigidbody or CharacterController on one of the colliders?
How fast is your object moving? It is possible that one collider is passing over the other without generating a collision. If this is the case, it would be better to adjust your scene, but if that is not feasible, then if you have a Rigidbody, you might consider changing your Rigidbody's collision detection to Continuous.
answered Oct 27 '10 at 06:35 PM
I just spent a few hours banging my head against this problem... I found a solution by adding a rigidbody component, and opening the constraint dropdown of that component and checking all the boxes. This way, the object still collides with the trigger, but it's not at the mercy of physics, and it still obeys it's transform instructions.