Gorlog
January 26, 2011, 4:53am
1
hello there i have a simple animation code here
function Start()
{
var clip: AnimationClip = new AnimationClip();
var event: AnimationEvent = new AnimationEvent();
clip.AddEvent(event);
}
function Update(){
if(MoveAround.Anim_Check > 0)
{
animation.Play("Hit_Anim");
}
}
code works great but animation is looping i need to animation Anim_Check > 0
play it and stop it but loop forever i change the animation loop to once but nothing happend any ideas?
function Start () {
// Set all animations to loop
animation.wrapMode = WrapMode.Loop;
// except shooting
animation[“shoot”].wrapMode = WrapMode.Once;
// Put idle and walk into lower layers (The default layer is always 0)
// This will do two things
// - Since shoot and idle/walk are in different layers they will not affect
// each other’s playback when calling CrossFade.
// - Since shoot is in a higher layer, the animation will replace idle/walk
// animations when faded in.
animation[“shoot”].layer = 1;
// Stop animations that are already playing
//(In case user forgot to disable play automatically)
animation.Stop();
}
function Update () {
// Based on the key that is pressed,
// play the walk animation or the idle animation
if (Mathf.Abs(Input.GetAxis(“Vertical”)) > 0.1)
animation.CrossFade(“run”);
else
animation.CrossFade(“idle”);
// Shoot
if (Input.GetButtonDown (“Fire1”))
animation.CrossFade(“shoot”);
}
Maybe this can help.It helped me with my game
Gorlog
January 26, 2011, 2:57pm
4
but ur using on animation input command
my problem is tank if hit one time animation play one time if try this
animation[“shoot”].wrapMode = WrapMode.Once;
nothing happend
Gorlog
January 26, 2011, 6:24pm
5
ok i solved this
gameObject.SampleAnimation(animation.clip, 0);