Between the Folds #006 - SwarmSquiddies


As you may know, the whale that WHALIEN takes place in is infested by slimy little Squiddies - it’s why the player takes on his adventure in the first place. In order to properly convey the infestation, we needed to be able to place large masses of Squiddies that don’t have a significant impact on the game’s performance. Therefore, we created the SwarmSquiddies which are spread all across the interior of the whale, covering walls, floor and decor.


Implementation:

 Having large masses of Squiddies means rendering many of the same meshes simultaneously, which instanced static meshes are predestined for. In UE4, instanced static meshes are managed using the UInstancedStaticMeshComponent, which can dynamically add or remove instances and can be used to adjust their transform. We split up the logic between the SwarmSquiddieManager, which controls the rendering of the meshes, and the SwarmSquiddieInstance, which handles the transform and logic for each individual Squiddie. This includes the Squiddie being highlighted, influenced or defeated by the player.     Whenever we create a SwarmSquiddieInstance, that actor registers itself with the SwarmSquiddieManager in that level and is assigned a static mesh instance. In order to provide a little more variance in the distribution of the Squiddies, we have the SwarmSquiddieManager manage three different UInstancedStaticMeshes. The SwarmSquiddieInstance is assigned one of those three meshes at random when it is placed in the editor.

With our current implementation, we can place around 2.000 SwarmSquiddies in an empty level, while the frame rate remains at 50+ fps on a mid-tier PC. The player can interact with all of these Squiddies.

(Mrs. Pull attracting a mass of SwarmSquiddies)

(Mr. Push repulsing a mass of SwarmSquiddies)


Highlighting:

 As mentioned before, we want to be able to highlight when the instanced mesh is in range of the player’s forces. Since we handle this via a post-processing effect, and instanced meshes cannot apply different post-processing parameters for individual instances, we needed to create another UInstancedStaticMeshComponent for the highlighted version of each mesh. Whenever the SwarmSquiddieInstance overlaps with one of the player’s forces, it reports to the SwarmSquiddieManager and is assigned a highlighted instance instead of the regular one.

(SwarmSquiddies that are in influence range are highlighted)

Extras: 

 In order to make the SwarmSquiddies feel a bit more lively, we decided to let them wiggle at random intervals and emit sound- and visual effects when they are defeated. We achieve the wiggling by adjusting the Squiddies’ rotation according to a timeline, which unfortunately impacts the game’s performance, but we felt this trade-off between performance and liveliness was worth it in this case.


Placement:

 We decided to use the foliage tool provided by UE4 for convenient placement of multiple Squiddies at once. This is achieved easily by creating an “Actor Foliage”-object and specifying the actor to spawn using the foliage tool. The foliage tool can then be enabled by switching from Select to Foliage in the toolbar. The individual brush settings also allow for variations in scale and rotation, which is very convenient for us.

(Left: Brush settings when creating the "Actor Foliage"-object. Right: Settings when selecting the brush for foliage painting.)


(Painting a concave object with SwarmSquiddies)


(Removing the previously placed SwarmSquiddies)

Future improvements:

 In the future, we want to test if we can further reduce the performance overhead of our SwarmSquiddies. We would first attempt to implement them as a Niagara Particle System and see if that can help with the performance overhead of the Squiddies’ wiggling. This could potentially work by employing a single animation across all Squiddies. They should still keep their functionalities, like being influenceable and highlighted by the player, so it remains to be seen if we can achieve this with Niagara. .

As always, if you have any inquiries about our SwarmSquiddies, or can think of any neat performance improvements for them, do not hesitate to let us know!

Leave a comment

Log in with itch.io to leave a comment.