Overview
This simple script allows you to easily switch between two meshes, intended for use with some of the Harrowing High assets that have two version. You can run this on a server or for a specified client. You can also time an effect and sound to play when the switch occurs.
Package Content
HighSchoolCrate (Template) - Example of a wooden crate that switches between normal and a horror version. This changes after a small delay and runs on init.
HighSchoolContainer (Template) - Example of a food container crate that switches between normal and a horror version. This changes after a small delay and runs on init.
HighSchoolFoodCounter (Template) - Example of a food counter that switches between normal and a horror version. This is setup so it can be triggered and doesn’t run on init.
HighSchoolLocker (Template) - Example of a locker that switches between normal and a horror version. This changes after a small delay and runs on init.
meshSwitchableScript - This is the main script that triggers the meshes to switch and can have extras like sounds/effect when this happens.
Setup
First, install the package by going to the Community tab and searching for “Mesh Switcher”.
How to use
- Create a Locator in the world and attach the meshSwitchableScript to it.
- Place two meshes as a child of this locator, for example Mop Bucket and Mop Bucket - Horror
- On the Locator look for the Meshes group and apply the Starting Mesh and Ending Mesh, in our example that is Mop Bucket and Mop Bucket - Horror
- Optionally we can set an effect to play and a sound to play.
- You can also make other changes like delaying the time to switch, the effect and sound to trigger, or disable it changing on start.
- Once you have set this up, simply Preview the game.
- Finally, and optionally you can select the Locator that contains the meshes and choose Template > Create New Template … and name it something suitable i.e. Spooky Mop. Then you can drop this template in whenever you need it.
Script Properties
startActive - Should this start when the game is active, disable to trigger this later.
swapDelay - A delay until we start the mesh swap.
runOnClient - Do this on a specified client that you have passed to this script. i.e. via a OnTrigger function.
startingMesh - The mesh you want to start with.
endingMesh - The mesh you want to swap to.
effect - Effect to spawn as the mesh is swapped.
effectPosOffset - Add offset to the position of the effect spawned.
effectRotOffset - Add offset to the rotation of the effect spawned
effectsDelay - A delay that can be set so you can time the effect and the mesh swap.
effectHasLifetime - Do we want to manually set a lifetime for the effect to last.
effectsLifetime - Lifetime to have the effect active for after mesh swap.
sound - Sound to spawn as the mesh is swapped.
soundPosOffset - Add offset to the position of the sound spawned.
soundDelay - A delay that can be set so you can time the sound and the mesh swap.
soundHasLifetime - Do we want to manually set a lifetime for the sound to last.
soundLifetime - Lifetime to have the sound active for after mesh swap.
animName - String name of animation to play on swapping mesh.
Useful things to know
If you select client you can use a trigger to call an event then use the functions SwitchForward(other) to switch from the startingMesh to the endingMesh and pass the user as other. You can also use SwitchBack(other) which has the reverse effect.
There is an example BP if you search for Mesh Switcher Example when you go to Create a game.