I've made many colliders before and that I used was (collider otherOnTriggerEnter(collider other)) and then check if the other collider is the one I want by comparing TAG. But this time I'm not triggering the canMelee boolean. My code:
ArrayList Enemy;
public StatData stat;
[SerializeField]
private bool canMelee = false;
/// <summary>
/// OnTriggerEnter is called when the Collider other enters the trigger.
/// </summary>
/// <param name="other">The other Collider involved in this collision.</param>
void OnTriggerEnter(Collider col)
{
if (col.tag == "Enemy")
{
Debug.Log("Now you can do melee attack!");
canMelee = true;
}
}
So I wrote this code but somehow this doesn't work I checked the tag and added it to the player game object but it still doesn't work.
I tried to add another debug to check if OnTriggerEnter() is happening just above the if branch : Debug.Log("Triggered"); and it gets triggered.
I can't just figure put what's wrong. Please help me.
col.taginstead of"Triggered". - AresCaelum