Problem with Coverting JS(UnityScript) to C#

Hi guys
Well I am a Intermediate Programmer in C# and I wouldn’t like to use JS as I already have a good standing in C# but the problem is that I just can’t make the:

if(Input.GetAxis("Vertical") || Input.GetAxis("Horizontal"))
{

}
else
{

}

JS Code

to

if (Input.GetAxis("Walk") || Input.GetAxis("Horizontal"))
            {

            }
else
           {
           }

CS Code to work.


What error are you getting, is always the thing we like to know.

A completely random shot in the dark guess, since I don’t know exactly what your problem is, is that GetAxis returns a float, not a boolean, and C#'s strictness does not want to || two floats. Try comparing the GetAxis-es to something and see if that helps.

That’s exactly it; you need to say something like:

Input.GetAxis(“Walk”) != 0

Well actually I am following THIS tutorial. And all the scripting is done with JS.

if (Input.GetAxis("Walk") [B]< 0[/B] || Input.GetAxis("Horizontal") [B]> 0[/B])
            {

            }
else
           {

           }

FizixMan is it something like this you are talking about?
Well its working!
Thanks!

VILE

P.S. Sorry! I was in a hurry yesterday, I posted this just before went to sleep(My Mom was scolding me!)

For Input.GetAxis(“Walk”) to be recognized, it needs to be set up in the input settings for your project. Has it been set up?

If not, click Edit > Project Settings > Input

That may be the problem if it’s not working.

Good thing it’s working for you now, though!