OnTriggerEnter
Hey
I got a ball falling trough a Box, like the tutorial, did everything like the tutorial.. nothing happens
using System.Collections;
using UnityEngine;
public class IsRange : MonoBehaviour {
void OnTriggerEnter(Collider col){
Debug.Log ("Collision");}
}
I have Rigid Body on both objects. I have the Is Trigger Checked on both Objects. Both Objects have the script attached.
Got no output from the script, no Log Message no nothing any idea?
I'm using Unity 3D 5.5.0f3.
Thanks in advance
Answer by tanoshimi · Jan 21, 2017 at 07:12 AM
Your code snippet is called IsRange, yet your screenshots appear to show a component called IRange. Are you sure you've attached the right script?
It's a typo but thanks for cathing this little fellow, i'm going to change it. But it's the only script in the project so I dont think is from this one.
Answer by opnsrc · Jan 21, 2017 at 09:16 AM
Try finding the trigger with a conditional statement
public void OnTriggerEnter(Collider other)
{
if (other.tag == "Player")
print("Player found");
}
Set your cube as other and put this script onto sphere to differentiate.
Thanks I'll try it, i know i tried using a conditional statement with tag or name and it dis nothing. To be honest they were both trigger and both had rigids.
Hey Thanks a lot i tagged the SPhere as player and changed the little Typo, AND IT WOR$$anonymous$$S <3 thanks guys u're awsome
If LPkster's answer solved your problem, then Accept it and close the question :)
Your answer
Follow this Question
Related Questions
how to get collision to control servo motors 0 Answers
Unity 2D colliders not triggering,Unity 2D collider not triggering 0 Answers
Infinite Collision? Can't figure out bug 0 Answers
How to detect collision of two moving characters? 1 Answer
How to move and rotate to other direction when hitting a wall 1 Answer