Okay, i had some problems with some triggers so i decided to go back to the basis to see what i was overlooking… i went all the way back to the script in the Script reference but even that is not working:
function OnTriggerEnter (hit: Collider) {
Destroy(hit.gameObject);
}
to test it, I simply put the script on a cube and made it a trigger.
then i made a sphere above it with a rigidbody, but the sphere just falls throug the cube?!?
i must be missing something very basic.. please help me
Thx.
Yes the cube does have a box collider with “is trigger” enabled, and yes the sphere has a collider and the script is assigned to the cube… you can see why im confussed
My issue was completely different. I use Visual Studio to code and I had a test project open where I was editing scripts in VS attached to that project. I started a new project to start over once I had everything in order. I was still editing the scripts form the other project and wondering why no changes. I imported the script from the other but was still editing the originals. Silly I know but make sure you have VS or that other one (Mono Develop) actually editing the file in your current project. Was driving me nuts.
If your OnTriggerEnter not working there are a few ways to fix this firstly you need to add trigger component for 2 object ,Player and Cube then you need to enable is trigger feature for cube then you need to add rigidbody component for both object when you do these steps it will be work without any problem =)