Question by
UniluckStudios · Jul 16, 2017 at 02:43 AM ·
animationanimator
Death animation wont work when I collide with a 2d Collider
I am trying to make my character play an animation when i hit any object except for the background. I have the animator set up so that a trigger called "Death" happens when I collide with a 2d collider. This is my code:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class BallAnimationScript : MonoBehaviour { bool dead = false;
Animator animator;
// Use this for initialization
void Start () {
animator = transform.GetComponentInChildren<Animator> ();
}
// Update is called once per frame
void Update () {
}
void OnCollisionEnter2d(Collision2D collision) {
animator.SetTrigger ("Death");
}
void FixedUpdate (){
if (dead)
return;
}
}
I also have a error that says "cannot preview transition. Source state does not have motion"
Comment
Your answer
Follow this Question
Related Questions
Humanoid Animations 0 Answers
How to make player rotate 180° and run that direction with mecanim + vice versa? 1 Answer
Animator vs Animation Clip via Scripting 0 Answers
How to Apply Animation to Player 0 Answers
Opening Cutscene 0 Answers