- Home /
After collision how the run animation to die animation will change..
Hello,
I am Beginner ,..now i started one game,in that after collision the walking charecter change to die animation...please once check my code..
void OnControllerColliderHit(ControllerColliderHit hit)
{
if(hit.gameObject.tag == "enemy") {
Debug.Log(hit.gameObject.tag);
//Destroy(gameObject,5); Destroy(hit.gameObject);
gameObject.animation.Play("jump_pose");
Controller2D.lives -= 1; //hit.gameObject.animation.Play("die");
StartCoroutine(Example());
if(Controller2D.lives == 0) {
Application.LoadLevel(2);
}
// LoadAScene();
}
if(hit.gameObject.tag == "staircase") {
//Debug.Log(hit.gameObject.tag);
animation.Play("walk",PlayMode.StopAll);
}
if (hit.moveDirection.y > 0.01f)
return;
// Make sure we are really standing on a straight platform
// Not on the underside of one and not falling down from it either!
if (hit.moveDirection.y < -0.9f && hit.normal.y > 0.9f)
{
activePlatform = hit.collider.transform;
}
}
IEnumerator Example() { yield return new WaitForSeconds(1);
Application.LoadLevel(1); }
Are you trying to create the animation on the player or the hit enemy? Your code seems to show that the enemy is supposed to have a die animation. Problem is you destroy your enemy. You need to keep the object alive until he finishes dying.
Your answer
Follow this Question
Related Questions
resolutions 1 Answer
About ListItems in Unity3D 1 Answer
how to use specific touch in unity for iphone and ipod 1 Answer
How to create button for jumping in unity3d for iphone 1 Answer
How To Crop the Gallery image for iphone in unity3d 0 Answers