Performance Optimization
Last updated
Last updated
Before diving into this tutorial, it's crucial to issue an early caution against premature optimization. The Miss No Hit system is inherently efficient right from the start and is unlikely to cause performance issues unless there are an exceptionally large number of active tracers, typically in the tens of thousands. Thus, it's imperative to initially confirm the existence of a performance problem induced by Miss No Hit. This verification can be easily executed by entering the command "stat missnohit".
In the depicted scenario, the cumulative execution time of all Miss No Hit events, encompassing Blueprint actions following the "On Hit" execution pins, is around 2 milliseconds. Further insight can be gained by calculating the Blueprint event execution times through the subtraction of "Exclusive" values from "Inclusive" values in the "Tracer Control Node Hit Detected." This analysis reveals a discrepancy ranging from 1.3 to 1.5 milliseconds, indicating that the majority of the performance bottleneck lies within the Blueprint code.
In this second example, we intentionally engineer a scenario to create a bottleneck in the MissNoHit system. Here, we spawn 10,000 actors, each equipped with active tracers. To initiate the tracers, we utilize the non-event blueprint node "Start Tracers."
These statistics reveal that a significant portion of the computation is consumed by the "Do Trace" method in an inclusive manner. This indicates that the bottleneck lies in the execution of trace operations.
Under these circumstances, a primary optimization involves scrutinizing the precision of the "Trace Settings." Ideally, these settings should guarantee that traces exclusively occur against the channels or objects of interest, excluding all others.
With the current settings, the system performs traces against every object that responds affirmatively to the Visibility channel, which may include a substantial number of objects. If, for instance, the objective is solely to check hits against Pawns, adjusting the settings to narrow the scope is advisable.
Upon reviewing the statistics again, it's evident that this modification has led to a substantial speed-up, approximately doubling the system's efficiency.
Another crucial optimization involves reducing the tick rate. Unlike traditional collision components, the Mnh system conducts traces between the previous and current locations of the hitbox, ensuring accurate hit detection even at significantly lowered tick rates. By setting the Tracer Tick Type to "Fixed" with a value of 10, we observe a further reduction of around 2.5 times. This adjustment allows the system to process 10,000 active tracers in approximately 4 milliseconds. It's important to note that the values demonstrated in this tutorial are derived from a hand-crafted scenario and may not be precisely applicable to your specific game.
The optimal values for these parameters vary from game to game, depending on the specific use cases and scenarios involving tracers. As a general guideline, we recommend a 60Hz Fixed Rate for player characters and a 20Hz Fixed Tick Rate for NPCs. However, it is crucial to conduct thorough testing and evaluation of the system's behavior within your game to strike the right balance between speed and efficiency and achieve optimal performance.