- Home /
Get animation work
I want to make "shoot" animation being played each time only after bullet shot out. Here's my script:
private var _animation : Animation;
var Bullet : Transform;
var Speed = 500;
var spawnPoint : Transform;
var Counter = Time.deltaTime;
var RateOfFire = 0.250000;
var target : GameObject;
function Shoot() {
yield WaitForSeconds(0.1);
Counter += Time.deltaTime;
if(RateOfFire<Counter){
var shotRapid = Instantiate(Bullet, spawnPoint.transform.position,
Quaternion.identity);
shotRapid.rigidbody.AddForce(transform.forward * Speed);
Counter=0;
}
}
So how can it be achieved? Thanks in advance for your feedback :)
Comment
Best Answer
Answer by clunk47 · Sep 13, 2013 at 02:53 PM
Assuming you have an animation named "shoot": You could use a Keydown event, add Animation.Play() or Animation.CrossFade to the statement. You COULD just add it to your shoot() function as well, since you're jumping to it in this example anyway.
function Update()
{
if(Input.GetMouseButtonDown(0))
{
animation.CrossFade("Shoot", .1f);
Shoot();
}
}
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Shooting & Animation Problem 1 Answer
Animation play when player collides/hits an GameObject 0 Answers
How to Sync bullet spawn with shoot animation 0 Answers
SimpelTimerScript 1 Answer