- Home /
Instantiating animation with a spawning prefab
Hi, I am having trouble with the position of my animation. In my game enemy ships spawn randomly. when they collide with a bullet, I want my explosion animation to play. But the problem is, I can not figure out the position of it. Animation should start on the enemy ship's random position. How can I do this. Here is my code. 
Answer by dishant27 · Feb 24, 2018 at 03:46 PM
In the ExplosionAnim(), transform the position of the created gameobject "Explosion" which is holding your instantiated gameobject:
Explosion.transform.position = transform.position;
No, it does not work. Animation is starting outside of the camera for some reason. Any other solution?
Can you share more about how you have created the animation?
I created my animation using sprite editor. i sliced the grids by cell size. Then I made my animation a prefab. In my game when the enemy bullet touches the player, I made the animation play at that specific position where the bullet touches. I did not have any problem doing this. But I am having problem setting the animation's random position. Wherever the enemy spawns, the explosion animation should also start there when the player's bullet touch. What do you think I can do? By the way my first language is not english so I did my best when writing this.
[1]: /storage/temp/111929-explode-1.png
Your answer