- Home /
How to make bullet explosion animation occur at the time it collide?
I wanna ask, I successfully make a bullet explosion when the bullet collide. But the explosion didn't occur in the same place of the bullet collide. For example, if the bullet collide in the middle, then the explosion will be occurred in the left. I'll give my bullet script down below,Hello I want to ask, I've successfully make a bullet explosion when the bullet collide with obstacle. But the animation is a bit off. Like it didn't explode in the place of the collide but next to the collide position. For example, if the bullet collide in the middle then explosion will be played on the left. What error is this? I'll my bullet script below
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Bullet : MonoBehaviour { public GameObject hitEffect;
void OnCollisionEnter2D(Collision2D collision)
{
GameObject effect = Instantiate(hitEffect, transform.position, Quaternion.identity);
Destroy(effect, 0.3f);
Destroy(gameObject);
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613061002im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Can the animation editor create local rotational data? 3 Answers
Rotation problem of two different prefabs 0 Answers
Adding animation clips via script 2 Answers
Quick way to reproduce fully rigged, animated prefabs with different meshes/Materials? 1 Answer
Scripting BUG: target becomes bigger when getting nearer 1 Answer