- Home /
having an event play at a certain time durring an animation?
So I know about the Animation Event tags in the Animation window, but on the animations I have made for a character in blender it wont let me create any. I currently have the rig set to legacy due to the animations not working on any other rig sadly. Anyways back to the problem, I want to "Damage a monster when a sword collides with it, or I hit it with a blast attack, the problem is i have to hold down the "Swing Sword" or "Blast" Button so that the animation will play all the way through, and doing so causes the "Attacks" to spray like crazy causing me to be able to deal 100+ damage by taking off only 5-10 damage per attack animation. Can someone help me to get the animations to play through without having to hold down their respective buttons, and also fix the code to somehow wait for a certain time on the animation to actually register the attack? Thank You in advance.
If needed here is my code.
//Small Blast
var projectile : Transform;
var bulletSpeed : float = 10;
var CoolDownTimer : float = 0;
var CooledDown : boolean = true;
if(Input.GetButton("Blast") && CooledDown == true)
{
animation.CrossFade("SmallExplode");
CooledDown = false;
var smallBlast = Instantiate(projectile, GameObject.Find("spawnPoint").transform.position, transform.rotation);
smallBlast.rigidbody.AddForce(smallBlast.transform.forward * bulletSpeed);
CoolDownTimer += 100;
}
if(CooledDown == false)
{
if(CoolDownTimer >= 1)
{
CooledDown = false;
}
else
{
CooledDown = true;
}
CoolDownTimer -= Time.deltaTime/1.5;
}