#Components

1 messages · Page 1 of 1 (latest)

hot fern
#

how to know where to get the component from
for example:

Animator: gameObject.GetComponent<Animator>();

BasicRagdoll: gameObject.transform.root.GetComponentInChildren<BasicRagdoll>():

gusty hedge
#

depends on what you're doing

hot fern
#

perhaps it is somewhere in assembly-csharp

gusty hedge
#

can you provide more context?

#

GetComponent gets the component on the same GameObject so if you know it's the same then call that

hot fern
#

i just don't understand when you need to get a component and when you need to get it from the parent or child

#

this is the main problem for me

gusty hedge
#

right

#

you'd need to know the hierarchy of objects

#

e.g. a player model may have multiple hitboxes, so you'd need to find it in the parents
though HitboxIdentity caches the target player

#

why do you need to do that for BasicRagdoll in the original message thuogh?

#

are you doing collision checks?

hot fern
gusty hedge
#

i guess what you can do is try GetComponent first, if that fails, use GetComponentInParent

gusty hedge
#

you can print it out Kek

gusty hedge
#

nope

#

in what scenario do you need to do this though