Toggling Solid object layer on/off at runtime through code

ICC90

New member
Hey there! really happy with the UFPS, I'm fairly new to gamedev and C# so forgive me!

I want to toggle a layer on/off in the solid object layermask at runtime so my character can run through certain objects. I have tested in the inspector by toggling the layer on/off in the solid objects field during play and it works as I'd want it but the script is just a tad too advanced for me to figure out where that is in the LayerManager/CharacterLayerManager script.

I have a script on the player that is ready to call a method that does this but can't seem to figure out which script I'd need to reference and if there is a method in either script that can do this.

Thanks so much for your time!
 
You should use the state system, and might not even need any coding.


1.) Create a new state preset for the CharacterLayerManager component.
2.) Add the solid object layermask as a parameter, and set the intended layers.
3.) You can either activate the state via code (see documentation above), or you can use the StateTrigger component. Create a trigger collider around your object, and add the StateTrigger component. Set the state you want to activate.
 
Top