#Help

1 messages · Page 1 of 1 (latest)

wispy merlin
#

How can i change the layer of game object through script? if someone could help me that would be grateful

blissful drumBOT
#
Rule #9. Don't spoonfeed or ask to be spoonfed

Before asking for help, please google your issue first, attempt to solve it yourself, and then ask. You learn more this way than being spoon-fed!

ancient hearth
wispy merlin
#

Why do you guys think i don't search on google

ancient hearth
#

because this question is easily googleable

wispy merlin
#

i come here after searching and not finding or understanding what i need

wispy merlin
ancient hearth
#

then why didn't you say that?

#

all you did was literally ask how to do something, which is easily googleable

wispy merlin
#

hey can you help me

#

i saw this code for changing layers through code everywhere

#

i don't know if i'm doing it right or wrong

#

gameObject.layer = 12;
gameObject.layer = LayerMask.NameToLayer("FpsLayer");

#

is this a right way?

ancient hearth
#

Syntactically fine, logically weird

#

Why are you setting layer to 12, just to change it again right after?

wispy merlin
#

i don't know i just saw it thought i should try it

ancient hearth
#

but setting it to 12 is doing nothing here

wispy merlin
#

if i remove it then?

restive turretBOT
#

Try it!

Whenever you ask "can I do X" or "will Y work", the only thing you are doing is wasting time (including your own!)
The people you're asking aren't computers, humans can be wrong in their answers. We also don't have access to your project or know your intentions.
The only way to know if something works as you wanted it to, is to try it for yourself!

wispy merlin
#

i tried, didn't work

#

all i want is when the player equips a weapon the layer on that weapon should change

ancient hearth
#

then perhaps your layer name is wrong

wispy merlin
#

name is fine too

#

i have a ground layer on the ground objects and the main camera is rendering it and for the weapons i have a weapon layer and the other child camera is rendering it

#

and because the other child camera is not rendering anything else expect for the guns you can see the guns through everthing