Author: Matthew Chadwick
Date: 11/10/2023
In CyberSiege, when an enemy dies, an invisible collider spawns on the enemy's corpse. When a player steps over the collider, it begins dispensing pieces of scrap that then flies towards the player. There was an issue where the scrap spawner was being triggered by the turrets accidentally shooting them. This resulted in large amounts of scrap being shot into the air without an actual target to move towards. Since the scrap would never despawn or be collected, the hundreds of scrap entities would cause large amounts of lag and drops in framerate. To resolve this, I needed to find a way to prevent other colliders from triggering the spawners.
After considering the options, I decided to use an interface since it would be the easiest to implement and require the fewest amount of changes. An Interface in Unreal Engine is a class that other classes can implement. The whole point of an interface is that it contains a number of abstract functions that are later defined in the classes that implement the interface. This allows a developer to achieve different behaviors for a singular purposing, like triggering an effect or, in this case, checking if an entity can trigger the scrap spawner. In the interface, I defined a single function that returns a boolean value which is used to determine if the entity can activate a scrap spawner. After implementing the interface in the player class, I was able to then check in the scrap spawner class if the actor it collided with had implemented the interface or not.
As a result of the newly implemented interface, I was able to reliably check if an entity was able to collect the scrap from the spawner or not. Since I was now able to set whether an entity should be able collect the scrap from the spawner, I was able to prevent accidental misfires of the spawner, resulting in an overall increase in performance. As a side note, I also noticed that the large amount of scrap while using the spawner correctly was also causing a lot of lag. To remedy this, I was easily able to reduce the amount of polygons in the mesh, which also improved performance.
Did you like this post? Tell us
Leave a comment
Log in with your itch.io account to leave a comment.