#`theObject` is whatever object whose
1 messages · Page 1 of 1 (latest)
No
GameObject names in the hierarchy are meaningless in code
unless you've actually made a field called Player and dragged that object in there
i havent done that
If you haven't done that then I'm seeing another issue here
which is your code editor is not properly configured
You should go to the IDE Configuration guide in #854851968446365696
Otherwise you're going to have a very hard time writing code.
You set up a reference to it
the name is not really meaningful in code
can I share the code here?
Yes as long as you follow the code sharing guidelines in #854851968446365696
- You can't just randomly put code floating outside a method like that. It needs to go in a method
- You haven't created any variable called "Player" here so you can't use a nonexistent variable
Also as I said above if you just want to change the name of the object the script is attached to you don't need such a thing at all
I want to call it
you want to call what?
what does this have to do with GameObject names?
i need to know the name to use it instead of sphere
I know you're just learning, but GameObject names are just for convenience in the hierarchy window
You very rarely do anything related to GameObject names in code.
You do not need to know the name of any GameObject to use it
Just reference it
public GameObject Sphere;``` for example
and drag and drop it in the inspector
no
your variable is called Sphere
the GameObject can be named anything
the name of the GameObject is irrelevant
so what should i put instead of the ---?
if(---.isGrounded)
{do stuff}
(dont mind the code, ik the syntax isnt correct)
wait sorry
what is isGrounded?
is that something you defined somewhere?
and what is it supposed to refer to? Some variable on some other script?
Somethign about the object your current script is attached to?
So you want to use CharacterController.isGrounded?
What was all this stuff about changing names?
yep
So get a reference to your CharacterController
and then you read it from there
how can i do that
as I've been saying
make a reference
assign it in the inspector
public CharacterController myCC;```
Assign this in the inspector^
Then you can do myCC.isGrounded
like in a new script?
i dont know, how am I supposed to assign it to the inspector window?
drag and drop
the text?
wtf
no
the component
the object with the CC on it
Honestly you need to take a step back
take some tutorials like this https://learn.unity.com/course/create-with-code
In this official course from Unity, you will learn to Create with Code as you program your own exciting projects from scratch in C#. As you iterate with prototypes, tackle programming challenges, complete quizzes, and develop your own personal project, you will transform from an absolute beginner to a capable Unity developer. By the end of the c...
you are missing the basic skills to script in Unity right now
this will help you learn
the object with character controller is sphere
yea xD
Thank you anyway for trying your best to help me, i wasnt expecting that much patience