C#- Activate Image effect Help
Hello, i have a small problem:
I want that if my health points are under 25- the image effect calles CameraMationBlur on the main camera is enabled. the script must be attached to my player, so i wrote: public GameObject cam;
if (hitPoints <= 25.0f){ cam = GameObject.FindGameObjectWithTag ("MainCamera"); cam.GetComponent(); CameraMotionBlur.enabled = true; } ...
it doesnt work. i always get this error :(
KerboEngine/Scripts/Player/PlayerCore.cs(1075,42): error CS0120: An object reference is required to access non-static member UnityEngine.Behaviour.enabled' and KerboEngine//Scripts/Player/PlayerCorer.cs(1073,25): error CS0029: Cannot implicitly convert type
UnityEngine.GameObject[]' to `UnityEngine.Camera'
:( Thanks for help :)
Answer by doublemax · Oct 10, 2016 at 08:03 PM
You probably wanted to write this:
cam.GetComponent<CameraMotionBlur>().enabled = true;
BTW: If the camera is tagged "MainCamera", you can access it directly using "Camera.main", you don't need the FindGameObjectWithTag().
Your answer
Follow this Question
Related Questions
Error CS0535? 0 Answers
Roll a Ball script error?! 2 Answers
NullReferenceException: Object reference not set to an instance of an object 1 Answer
Scene Won't Load 1 Answer
Socket: bind failed, error 3 Answers