top of page
Shifting Cover System
Scripting Explained
Construction Script
I wanted to be able to change any cover position's mesh and material on the fly in the editor so I created the first two functions. Starting Position Number is an enumerator that is used to switch between transform position sets. These are arrays that contain the transforms for one position. Currently, there are three positions.
Construction Script- Set Meshes From Array Function
The Cover Mesh Array that these meshes are being set from is public and editable as in it is exposed to the editor. The same mesh is set for the left and right side of the map. The Set Material from Array function is similarly constructed.
Position Number Enum to select starting Transform Array
Position Cover Transform Array 01-03 are public and editable and so is the enumerator Starting Position Number. The enum is used to select which transform array is the one the game starts with.
Set Transforms from Array
This function takes the starting array of positions and uses the Set Transform on Mesh function to do that on all the meshes.
Set Transform On Mesh
The same transform is being used for the left and right side of the mesh. Since the transforms are relative it worked to set the Z scale to -1 on the mesh components directly and that created a mirrored transform on the other side of the map. This is why the map is symmetrical. This function is used following the Array of Transforms Lerp in the Event Graph.
Event Graph
I have the Server starting the cover movement loop off of Begin Play. Each positional movement is multicast and runs on everyone. The transforms are replicated as well. All this seems to keep the movement fairly smooth and consistent across the server and client from my limited tests.
Array of Transforms LERP
This receives a linear ramp outputting a float from 0 to 1 over five seconds. This comes from the green input pin and updates all the lerps between one position to and the next. The Lerps are sent out into the Set Transform on Mesh function.
bottom of page