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

how do i make an Enemy take damage from prefab bullet clone?

$
0
0
i have the code for ray casting working well but im wanting to shoot a laser thatspawns a laster object that hits an enemy and it does damage to the enemy. i have gotten destroygameobject to work but not to take away health (i have it working with raycast it takes away health) for some reason when the laser collides with the enemy the laser destroy object works but the enemy is not taking damage i have tried to get component like i did with ray cast as well as made a collision on the enemy itself but i cant get it to take damage. When the left click is pressed it spawns the bullet prefab when the prefab spawns in the H it is named Bullet(Clone) i have also given it the tag laser nether has worked. i have tried void OnCollisionEnter(Collision col) { if (col.gameObject.name == "Bullet") { health -= 50f; } } void OnCollisionEnter(Collision col) { if (col.gameObject.name == "Laser") { health -= 50f; } } what am i doing wrong

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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