State Switcher package

Name: State Switcher
By AdamO on Discord

Created and demonstrated on a stream here - https://youtu.be/unOL6WvKl7M?t=4835

The State Switcher package allows you to switch visibility and collision on an entity and all of its children (recursively). You can also use it to switch or toggle visibility for a single client, using LocalToggleVisibility or LocalSwitchVisibility.

To set up:

  • Add the stateSwitcherScript to the root entity of any structure you want to change all visibility / collision on
  • Hook any event or function call into the state switcher, and call ToggleVisibility (will switch to the opposite state), SwitchVisibility (you tell it whether to be visible), ToggleCollision (will switch to the opposite state), SwitchCollision (you tell it whether to be collidable)
  • If you want to be able to change visibility on a client, add the LocalHandler script folder to the User template. You can then use the LocalToggleVisibility and LocalSwitchVisibility functions - for these, you must pass the player you’re changing the visibility for as the second argument

Examples uses:

  • Easily “turn on / off” large structures such as buildings with one function
  • Set structures visible/invisible for some clients and not others, e.g. you could have a team game with one team with “X ray vision”, where you hide solid walls for them and instead show glass walls
3 Likes

I’ve used this package a few times now and it’s great. One thing though – there is no function for “LocalSwitchVisibility” like you say in the description here. I’ve added it myself when necessary but it might be nice to include it outright for folks like myself that would rather say “make it invisible” instead of keeping track of an object’s visibility state and toggling it. :slightly_smiling_face:

Done! :tada: Thanks for pointing it out

1 Like

It looks like actually “last”, not “first”:

StateSwitcherScript:LocalToggleVisibility(player)
...
StateSwitcherScript:LocalSwitchVisibility(isOn, player)
1 Like

Amended, thanks :slight_smile:

LocalSwitchVisibility method is now missing again… And there are two packages now with same name, but neither have that method. One of them missing even the script…

Sorry missed this comment, but I think we resolved this on Discord, and it’s now all working as expected right?