guys im struggling over an hour on the 2d collision event. Currently I have 2 sprite’s each have a 2d boxcollider and are triggers. I have set the tag of one of the sprite’s to “player” but it still doesn’t work. I have already checked everything ten times and searched the internet for a solution…without success.
please help a fellow unity for the sake of the community xd
btw both sprite’s are animated, but I don’t think that’s the problem…
using UnityEngine;
public class collision : MonoBehaviour
{
void OnTriggerEnter2D (Collider2D other)
{
if (other.gameObject.tag == "Player")
{
Debug.Log ("why wont you work ;_;");
}
}
}
Another potential gotcha that I have encountered with collision triggers not working is if the Physics2D settings don't have interactions turned on for the the layers in question. So, for example, if you have objects in user defined layers such as Player and Missile, but you don't have the check box marked for Player/Missile collisions, then no triggers will be called. You can check your settings in Edit/Project Settings/Physics2D.
– TheotokosStill doesnt work for me, its set for 2D an using js, is trigger has be ticked for the chosen ones, they all have a Rigidbody2D and a circle collider, scripts all '2D's at the end of 'collider' and 'OnTriggeEnter-Exit' What can I do?
– FiltrateNevermind, is trigger needed to be unticked :)
– FiltrateThis is stupid ; I had the same problem (two collider2D, one was as trigger). I fixed it by adding a rigidbody2d component to one of my colliders. I don't even need any rigidbody behavior. Anyone knows why this is necessary ? Can't we just have colliders collide/trigger by themselves without rigidbody involved ?
– Myleskinematic means it is not affected by forces period not just gravity
– Mordy