var spellOne : Transform;
var coolDownOne : float;
var timerOne : float;
function Update () {
timerOne++;
if (Input.GetButton ("Cast1")) {
if(coolDownOne < timerOne) {
var instanceBulletOne = Instantiate(spellOne, transform.position, transform.rotation);
timerOne = 0;
}
else
{
if(coolDownOne > timerOne) {
print("Nope!");
}
}
}
So this is the basis of my spell system. It works beautifully. I press a button I’ve called Cast1 and it instantiates a prefab that functions as whatever spell I would like. I have one that acts as a fireball, another that works as a wall, and some others I’m toying with. I have a turret and two players using these spells right now, and I would like to use them with enemies once I get to that point as well, ideally.
What I need, though, is the ability for those prefabs to know who cast them. If Player1 casts a homing missile, I want it to be able to check for the nearest enemy and put that enemy into its Target variable. If Player2 casts a Blink spell, I want it to know that Player2 is the one who needs to move forward by a few feet. You get the idea.
How would I go about approaching that?