Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Trigger is not detecting tag

$
0
0
That's my code: void OnTriggerEnter(Collider col) { Debug.Log(col.gameObject.tag); if (col.gameObject.CompareTag("player")) { Debug.Log("Player died"); agent.setTrueIfHitPlayer(); instance.player.SetActive(false); agent.AIHitThePlayer(); //Destroy(instance.player, 1); } else { agent.setFalseIfHitPlayer(); } } This code is in the bullet object. And it checks if the bullet touched the player. The shooter is the enemy. I have set the tags to the parent obejct. This debug: Debug.Log(col.gameObject.tag); detects all objects but not the player tag. I don't know what I'm doing wrong. Is it because it is a prefab. And I also ticked the trigger to active in the collider of the bullet. The player is not a trigger.

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>