- Home /
HitSpark for Enemy Collision
Hey guys, I've got this plane with a working animated tiled texture which looks great, and the sequence it self is a hit spark (to show when something is hit). What I would like to do is make it so that whenever my spawned enemy is hit by the player's sword, the hitspark is created and stays on screen for 1 second. The problem is that since the enemy is spawned, it can't have a prefab to connect to the hitspark. Could anyone give me a hand?
Here's where the call to create the spark should go:
function OnTriggerEnter(hit : Collider)
{
if(hit.gameObject.tag == "Sword" && Walker.hitTimeSmall == true)
{
//////Insert Hitspark here!//////
Walker.hitTimeSmall = false;
health -= 1;
beingHit = true;
animation.CrossFade("gethit");
}
}
Answer by Alec-Slayden · Mar 01, 2011 at 08:59 AM
Create a "Resources" folder in your assets, and put the hitspark prefab in there. Then through script you can use Resources.Load to instantiate it
That worked but now the plane is facing upward ins$$anonymous$$d of forward, and rotating it doesn't do anything.
There's no reason you shouldn't be able to rotate it after instantiating it, as long as you are using the variable you loaded it into. If you are still having trouble, go ahead and add your current problems to your question including the script section where you load it and rotate it, and I'll see if I can add more to solve it