Coding/Scripting Help 3rd Person Lerpz Controller

Is there anyone that knows what this line of code would be in c# from js that is provided with the third person character controller script from the Lerpz demo?

var grounded = IsGrounded();

trying to translate the code from js to c# for a school project but this line just baffles me.

any help would be greatly appreciated.

thanks

Hi, welcome to the forum!

The main difference with C# here is that a variable declaration can’t infer the type from the return value of the function. You have to declare it explicitly:-

bool grounded = IsGrounded();

ok, thank you.

however now I have another question.

var cameraTransform = Camera.main.transform;

this line is giving me issues now…I assumed it would be transform for the variable in c# but unity doesn’t seem to accept that is there another variable name that is required for this type?

transform.cameraTransform = Camera.main.transform;

is what I thought it would be. I’m kind of going line by line in translating the code from JS to c# for this school project of mine so I’m hoping I won’t run into any more issues after I start figuring out more of the scripting and variable names for unity.
Still a little new to how scripting works in unity as you can tell from what I said earlier haha.

thanks

You need to specify the TYPE first, then the VARIABLE, and then the equals.

like this

Transform cameraTransform = Camera.main.transform;

TYPE (SPACE) VARIABLE (EQUALS)

Ok, thank you, I believe I tried that to but it still gave me an error. But I’ll give it another try and see if it takes it this time, in case I never did try that.