play .anim when i shot a asteroid/gameobject
So I need to get an Animation to play that I made using 3 sprites and the animation tool in unity, and I'm struggling to implement it, I've looked and a load of examples and it just doesn't work, here is the code I have for the asteroids
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Asteroids : MonoBehaviour
{
public float Torque;
public Rigidbody2D rb;
void Start()
{
rb = GetComponent<Rigidbody2D>();
float torque = (Torque);
rb.AddTorque(torque);
}
void FixedUpdate()
{
rb.AddForce(Vector2.down);
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("bullet"))
{
Destroy(other.gameObject);
Destroy(gameObject);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Door animation bugs and stays open unity 3D 0 Answers
MobController 1 Answer
Animator only plays the first few frames 0 Answers
Rotation animation keyframes problem 1 Answer
stickman animation 1 Answer