So i have an error in my script that i cant fix and i cant test my FPS game without. I know this is an easy fix but i am new to javascript and i dont even have a key that allows me to type | but i am able to copy and paste it.
The series of videos i am watching told me to put || but then i get the error in the title. So i tried putting only one | and then it came up with a different error
Operator ‘|’ cannot be used with a left hand side of type ‘float’ and a right hand side of type ‘float’.
I dont even know what that means!! If you know what is wrong then please help or if you know how to fix it i could really use your help too.
var Fire : String;
var Reload : String;
var Idle : String;
var Wlak : String;
function Update()
{
if(Input.GetAxis("Vertical") | Input.GetAxis("Horizontal")){
animation.Play(Walk);
}
else
{
animation.Play(Idle);
}
}
function FireAnim()
{
gameObject.animation.Play(Fire);
}
function ReloadAnim()
{
animation["Reload"].speed = (animation["Reload"].clip.length / Gun.ReloadTTime);
animation.Play(Reload);
}
Try the shift-\ key over the ENTER key. Try isolating both OR clauses with more parentheses, and add the arguments, like this:
if((Input.GetAxis(“Vertical”) == true) || (Input.GetAxis(“Horizontal”) == true)){
…
}
I’ve run across occasions when .net can’t OR correctly without explicit precedence. Although you certainly did have an error in your code with just one pipe (|) symbol. You tried to do a bitwise comparison of two floating decimal values; your values to the left and to the right of the equal sign were both ‘floats,’ when integers are required. The double-pipe compares TRUE to TRUE or FALSE to FALSE or TRUE to FALSE or FALSE to TRUE. That’s what you want.