[SIMPLE] On Collision Send ApplyDamage Message? (BULLET)

This isn’t the full script. The script is from a bullet and it already works detecting collision etc. However I can’t figure out what kind of sendmessage I will need to make the ApplyDamage work.

ApplyDamage is a function on the Enemy AI Script that reduces the enemys health on hit.

   function OnCollisionEnter(collision : Collision) {

       Target.SendMessage("ApplyDamage", Damage,   SendMessageOptions.DontRequireReceiver);

If I understand your question correctly you will want to replace your “Target” with “collision”. You want to send this message to the object that you hit. The object that is hit, in the particular code, is going to be called “collision”. If you only want to send this message to certain people do a check beforehand like:


Also it is important to note that you will need to use a raycast for fast objects. Sometimes when you use a cube, for example, as a bullet and shoot it really fast it might not register the hit on another object because its moving so fast.