#`theObject` is whatever object whose

1 messages · Page 1 of 1 (latest)

elfin cargo
#

like this?

hasty herald
#

GameObject names in the hierarchy are meaningless in code

#

unless you've actually made a field called Player and dragged that object in there

elfin cargo
#

i havent done that

hasty herald
#

If you haven't done that then I'm seeing another issue here

#

which is your code editor is not properly configured

#

Otherwise you're going to have a very hard time writing code.

elfin cargo
#

I mean how can i name something which i dont know the name

#

ok let me see

hasty herald
#

the name is not really meaningful in code

elfin cargo
#

can I share the code here?

hasty herald
elfin cargo
#

im installing vs for unity

hasty herald
#

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

hasty herald
#

you want to call what?

elfin cargo
#

like

#

if **sphere **is grounded

hasty herald
#

what does this have to do with GameObject names?

elfin cargo
#

i need to know the name to use it instead of sphere

hasty herald
#

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.

hasty herald
#

Just reference it

#
public GameObject Sphere;``` for example
#

and drag and drop it in the inspector

elfin cargo
#

so now my gameobject is called sphere?

hasty herald
#

your variable is called Sphere

#

the GameObject can be named anything

#

the name of the GameObject is irrelevant

elfin cargo
#

so what should i put instead of the ---?

if(---.isGrounded)
{do stuff}
(dont mind the code, ik the syntax isnt correct)

#

wait sorry

hasty herald
#

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?

elfin cargo
hasty herald
#

So you want to use CharacterController.isGrounded?

#

What was all this stuff about changing names?

elfin cargo
#

yep

hasty herald
#

and then you read it from there

elfin cargo
hasty herald
#

why are you sending a picture of that

#

that doesn't help us

elfin cargo
hasty herald
#

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

elfin cargo
hasty herald
#

no...

#

why would you need a new script

elfin cargo
#

i dont know, how am I supposed to assign it to the inspector window?

hasty herald
#

drag and drop

elfin cargo
#

the text?

hasty herald
#

wtf

#

no

#

the component

#

the object with the CC on it

#

Honestly you need to take a step back

#
Unity Learn

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

elfin cargo
#

the object with character controller is sphere

elfin cargo
#

Thank you anyway for trying your best to help me, i wasnt expecting that much patience