Quantcast
Viewing all articles
Browse latest Browse all 1488

Mario-Like Enemy Death System Not Working

I wrote this script that is supposed to delete the parent game object (the enemy) when something, not just the player, collides with the object this script is attached to. When I jump on the enemy, it does nothing and has no console errors. Here is my script: function OnCollisionEnter( collision : Collision ) { Destroy(transform.parent.gameObject); } edit I even tried another way of doing it, which uses the player to detect collisions, and it didn't work either. Here is the script: #pragma strict function OnCollisionEnter (col : Collision) { Debug.Log("Enemy About To Be Slain"); //to test collisions if(col.gameObject.name == "Enemy") { Debug.Log("Enemy Slain"); //to test the collider object name thingy Destroy(col.gameObject); } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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