Unable to get a collision

Hello,

I am scripting events to happen when they collide with player object, this codeworked at some point but than i did something i guess and now it no longer works, i tried to use trigger zones etc. but it didnt really help, i think i am missing something. I know this is probably something simple but i haven been searching for an answer for sometime and nothing works. I would love to know what are the requirements for collision detection to work. ( like having a rigid body etc, mesh etc.) Thanks in advance.

using UnityEngine;
using System.Collections;

public class onHitLoadLevel : MonoBehaviour {

	void OnTriggerEnter(Collider temas) { 
		if(temas.gameObject.tag=="Player"){ 
			print("hit"); 
		} 
	}



}

so this work?, you probably did something on the tag, or the collider of the player…try to check the editor rather than the code.

  • Colliders on both objects. Must not both be convex mesh colliders.
  • Rigidbody on at least one of the objects
  • For OnTriggerEnter() to fire, the collider should be marked as “Is Trigger”
  • For OnCollisionEnter() to fire, the collider must not be marked as “Is Trigger”, and the rigidbody must be non-kinematic.