- Home /
Screen Flash When Hit -- Error Help From Pervious Question's Answer
Hello. I am trying to make my screen flash red when I'm hit. I am following the first answer for this question: http://answers.unity3d.com/questions/24529/screen-flashes-red-when-taking-damage
I am getting an error though. I applied the given script, changing "GUITextureobjectname" on the 4th and 2nd to last lines to it's name in the Hierarchy. But I am getting this error:
Assets/Game Assets/Hit.js(15,10): BCE0017: The best overload for the method 'Hit.Fade(float, float, float, UnityEngine.GameObject)' is not compatible with the argument list '(int, float, float, System.Type)'.
and this error:
Assets/Game Assets/Hit.js(17,10): BCE0017: The best overload for the method 'Hit.Fade(float, float, float, UnityEngine.GameObject)' is not compatible with the argument list '(float, int, float, System.Type)'.
and I am unable to enter play mode.
I am calling the script with FlashWhenHit(); (outside of that script).
Can somebody tell me what I am doing wrong? Do I need to replace the value "float" for something, and if so, what?
Again, thank you!
:P
-Keavon
EDIT
EDIT
EDIT
EDIT
EDIT
EDIT
Thank you for your answer, efge, and Marowi for helping me understand it.
I have fixed it and it got rid of the error, but now I am getting:
Assets/Game Assets/Hit.js(15,10): BCE0017: The best overload for the method 'Hit.Fade(float, float, float, UnityEngine.GameObject)' is not compatible with the argument list '(float, float, float, System.Type)'.
And...
Assets/Game Assets/Hit.js(17,10): BCE0017: The best overload for the method 'Hit.Fade(float, float, float, UnityEngine.GameObject)' is not compatible with the argument list '(float, float, float, System.Type)'.
What should I do now? I suck at scripting, and I have never really gotten outside the cardboard box with it, so to speak.
Thank you so much for you input!
-Keavon
Answer by efge · Apr 07, 2011 at 06:17 AM
The arguments of your function Fade are Floats and a GameObject,
so you should change the calls to this:
Fade (0.0, 0.8, 0.5, GUITextureobjectname);
Fade (0.8, 0.0, 0.5, GUITextureobjectname);
Hey, thanks for your response, but I don't get what you mean. Where should that go? Because I have that already on line 15 and 17, with line 16 being yield WaitForSeconds (.01);
. Isn't that what I already have, or does that go elsewhere? Thanks!
The first 3 arguments passed to Hit.Fade() must be floats. On line 15, you're using (int, float, float...
and on line 17, you're using (float, int, float...
Your answer
Follow this Question
Related Questions
Screen flashes red when taking damage 3 Answers
Red flash for each network player when he gets hit 1 Answer
Cannot run anything in iOS. No errors! 0 Answers
Mouse look script help 1 Answer