Home>
Normally it is stationary, but I want to create a GameObject called fire that moves when the start button is pressed.
I struck the code while checking various things on the net, but it is exactly the same behavior as before adding the code.
The error is
MissingComponentException: There is no'Animation 'attached to the "fire" game object, but a script is trying to access it.
You probably need to add a Animation to the game object "fire". Or your script needs to check if the component is attached before using it.
Is coming out.
public void StartButton ()
{
flag = 1;
timer = 0.0f;
GameObject obj = GameObject.Find ("fire");
Animation anim = obj.GetComponent ();
anim.Play ();
}
I wrote, but it does not move at all.
-
Answer # 1
Related articles
- c # - i want to play animation to unity music
- c # - unity) show/hide prefab button conditionally
- c # - i want to be able to switch characters by pressing a button
- c # - about controlling unity animation
- c # - i can't attach a script in unity (beginner)
- c # - error when creating unity class
- c # - [unity] object reference not set to an instance of an object error resolution
- c # - i want to stabilize the processing cycle of unity
- c # - [unity] i want to paste multiple textures on a game object
- c # - unity delegate basic cs0246 error
- c # - code error of script implemented by unity cannot be resolved
- c # - i want to get the text of unity toggle group
- c # - visual studio 2019 does not open when double-clicking a unity script
- c # - player production in unity (shooting game)
- i can't press the button of the child form called from the c # parent form
- c # - i want to read a txt file with unity and store it in an array
- c # - unity: i want to move an object according to the moving platform
- c # - rotation control of 3d game objects in unity
- c # - unity) i want to get the image size in prefab
- c # - [unity] how to make a script that executes processing after a certain period of time
Related questions
- c # - player production in unity (shooting game)
- c # - please tell me how to use the additional components of unity's volunteer production
- c # - conversion from enum type to enum type
- c # - missingreferenceexception occurs even though there is a reference
- c # - i want to update the value
- c # - i want the camera to follow the player character in a tps game, but if i make multiple players in multiplayer, the camera
- c # - [unity] even though "has exit time" of animator is specified, it will transition to another state earlier than t
- c # - == becomes false even though the strings are equal
- c # - how to use start () in unity
- c # - in a script? error cs1056: unexpected character'?' is displayed even though there is no
If you look at the error code,
It looks like there is no Animation component attached to the fire object.
Attach the Animation component to the fire object and set the animation.