How to fix a compiler error?
Hi! I tried to enter play mode but a error appeared: "all compilar errors have to be fixed before you can enter play mode".
This error appears since i tried to make a script witch should make an animation play only when i click left.
Screen with the script that cause the error: https://postimg.org/image/h8o7p8lct/ Screen with the errors : https://postimg.org/image/hrbnwa0lz/ https://postimg.org/image/7fb9zoel5/
Can someone help me? Where is my mistake?
Answer by tanoshimi · Nov 01, 2016 at 11:03 AM
The error is very explicit: you've written animation.Play
, but not declared anywhere what "animation" is. If you want to access the animation component attached to the gameobject, you need to use:
GetComponent<Animation>().Play();
I also recommend you read the manual or some beginner's tutorials.
Answer by Anton-Korhonen · Nov 01, 2016 at 11:20 AM
The reference to animation is missing. In your start function, call
animation = GetComponent<Animation>();