I cant think of a good resource for this right now, but you can look at the Epic’s Youtube channel for videos like “Rendering Best Practices” and the like. Tbh, this is a skill you learn overtime as you get more experience coding.
The basic idea is to reduce redundancy in the code or code that runs frequently that doesn’t need to run. Think of all the code you plug to OnTick (runs every frame, so about 120 times per second!). Or any code that is attached to a timer that loops.
Look at variables that are set constantly that don’t need to be.
One example: You have an actor that will execute an action when the player is nearby (say a door opens automatically)
1 solution: You could run a custom event that runs on tick that checks the distance between the actor and the Player to determine the distance. If distance is less than X, open the door
A better solution: Use a box collision trigger and set it to overlap the player. If the Player overlaps, open the door.
Notice how in the second solution you aren’t running constant code.
A “heavy” calculation, for example, would be getting the location of all actors of class X in your level and then doing some calculations for each vector, on tick!
Example of the above:
I have a procedural asteroid filed using Instanced static meshes. I have thousands of meshes as part of the same actor. I run an event on tick that goes through all instances and rotates the mesh to simulate rotation of each asteroid individually. This means that every frame I will go thru thousands of meshes and applying a rotation. If you have too many meshes you will see an impact on your game.
When you are running your game, type ‘~’ for the console and type ‘stat unit’ to view how long it takes UE4 to draw a frame in milliseconds. The lower the number, the better
Hope this helps!