#okay

1 messages · Page 1 of 1 (latest)

teal lava
#

okay so

#

it always shows the else statement

winter tusk
teal lava
winter tusk
#

can't see GroundCheck() being executed anywhere.
Post All the code.

teal lava
winter tusk
#

I see a problem, brb 1min

#

inside your GroundCheck method

#

you define string StandingOn

#

however, this is not the same as setting the value of your class' variable
public string StandingOn;

#

when you define a variable within a call inside the class, it is not a variable field of the class, but a local variable of that method.

#

Do you see how the issue can be resolved?

teal lava
#

global?

teal lava
winter tusk
#

no

teal lava
#

idk thats how Python does it i'm new to C#

#

OH

winter tusk
#

C, C++ and C# are different languages

teal lava
#

I remove string StandingOn; from the class

#

so it reads the public one?

#

OR

winter tusk
#

when you say Remove from the Class

teal lava
#

?

teal lava
winter tusk
#

no

teal lava
#

hmpf

winter tusk
#
private int variableField;

private void myMethod()
{
   int localVariable = 0;
}
#

local variables must be initialized with a value

#

not at all the point, however

teal lava
#

i see

winter tusk
#

these are two different Levels of variables

teal lava
#

one's global and the other one is created and contained in the method

#

correct?

winter tusk
#

yes, precisely

teal lava
#

i have initialized global string StandingOn = "None" at the start of ThirdPersonCharacterController though

#

OH

#

The global string is different from the local string

winter tusk
#

the value can be null

#

yes

teal lava
#

I SEE

#

and how can i make it global

winter tusk
#

you set the variable with that name, instead of creating a local variable with the same name

#

it's one word less :)

teal lava
#

Let me try

#

YES

#

THANKS MATE

#

<3

winter tusk
#

You're welcome

#

Local Variables are faster to access, and they let us have a less amount of Fields in the class