|
Hello there! I just wanna know if there is a function that returns if there is an object in my hierarchy by checking its name or tag. situation: My character have 3 kinds of object to pickup, so I wanna check the name or tag of his hand child, how can I do it??
(comments are locked)
|
|
transform.Find(); I only want a confirmation about there is or isnt the object in the hierarchy OR an object with a tag, can transform.find return this information?? I have results to access things using transform.Find but not return if there is or not. Thanks in advance!
Jan 06 '11 at 06:26 AM
Dinart Filho 1
I just want something like "If (I am father of somebody called john){ doSomething();} or just "if there is somebody called john in my game, do something"
Jan 06 '11 at 06:33 AM
Dinart Filho 1
Please read the docs about transform.Find.
Jan 06 '11 at 09:04 AM
Eric5h5
Eric is right: "If no child with name can be found, null is returned." You can use that.
Jan 06 '11 at 10:24 AM
runevision ♦♦
You might try testing if (ergue != null)
Jan 06 '11 at 07:49 PM
DaveA
(comments are locked)
|
|
This can be solved as a one off for all transforms by using an extension method. It also doesn't require you to pass in redundant parent info. Usage: Thanks to you I read up on Extension Methods and man I've been missing out on some cool stuff! I started using them and I love them!!!!
Aug 07 '12 at 01:53 AM
ronronmx
(comments are locked)
|
|
transform.Find(); will only search the immediate children. To search a whole hierarchy (children of children) for a transform of particular name - call a function like this (.js)
(comments are locked)
|
|
Andrew 10 -- great answer! Thanks. I have taken your code and adapted it (JS) to use tags
(comments are locked)
|
|
Thank you Andrew 10 for your answer. I just used to selectively turn off a few buttons in a virtual gamepad implementation:
(comments are locked)
|
