I’m a beginner in unity and in programming the C#. I have a wizard with a moving script and a camera rotation script And i don’t know how to make him shoot a flame balls that explode with animation I already have the animation but don’t know how to write a script for firing the flame ball and playing the animation
. If anyone can help me ,please answer the question.
you need to create a particle system using the particle system gameobject that will look like your flame ball. then you make it a prefab and use Instantiate function to make it appear ingame. then you can make that instantiate trigger on any desired input like when you press the shoot key.
Yeah under a tab in the particle system there is an option for animated particles the animation has to be an animation strip. There are many ways to simulate a fireball, you don’t have to start with simpler stuff and you don’t have to start with 2D.
If you wanted to code the animation onto a plane or other 3d object you could make a public Texture2D array or List<>() add single images of the animation to the list. Then on void Update you could write something like gameObject.GetComponent.material.maintexture=texturearray[slot]; slot++; if(slot>texturearray.Count-1){ slot=0; } but dont actually use GetComponent every frame like that it’s slow lol get the renderer at start frame and store it in a variable or better yet make a public Renderer variable and drag and drop it in your editor.