help needed with accesing a variable in another script
im trying to acces isgrounded in another script and have it be the same as hi but i get this error
10 Replies
fallingplatform is the name of the script i wrote this in
playerscript is another script
Well,
access
has not been initialized with any value
And does playerscript
class even have an isGrounded
member?
Also, is that Unity?yea and yea its unity
That is a method
Methods are called
IsGrounded()
(they're named with PascalCase
too, btw)
(just like classes)ooooh
do you know how i can us the method in the other script
Considering how it's an instance method, you will need an instance of that class
If it's in a different namespace, that namespace will need to be imported
And, well, the method needs to be called of course
.IsGrounded()
not .IsGrounded
i have no idea how to do that
for example
i get an this error twice The contextual keyword 'var' may only appear within a local variable declaration or in script code
A field initializer cannot reference the non-static field, method, or property 'fallingplatform.script'
i also get this one
The contextual keyword 'var' may only appear within a local variable declaration or in script code
Means you can't do
A field initializer cannot reference the non-static field, method, or property 'fallingplatform.script'
Means you can't do