Hey again guys,
I am currently trying to get bullets working.
I have a system that spawns a space ship prefab, this spaceship prefab then moves around on its own and fires a bullet prefab, the bullet prefab use a script to detect collusion with an enemy spaceship prefab, I’m trying to get this bullet to call a function from whatever it hits.
To do this I’m using a sendmessage like this
function OnTriggerEnter( other : collider ) {
if( other.tag == “Player” )
{
var target : GameObject = other.gameObject;
target.SendMessage(“Take_Damage”, 1 );
}}
However this returns an error message saying there is no receiver and doesnt call the takedamage function.
Why is this? Its definatly hitting the enemy, the method i used before was actually setting a reference to the script of the enemy ship and calling the function by setting the collider object to the reference
However, different ships use different scripts (though they will all have the same Take_Damage function)
So i need something that can just call a function from whatever the script of the object it hits.
Does anyone have any idea of why this isn’t working, or rather a different way to do this?