Hit procentage system in UE5

I want to make a simple system where the game shows you at the end of the level the precentage of the accurate headshots compared to all of the fired shots but I dont know how to do that. I’m just starting my adventure in Unreal Engine and i was trying to make a simple game for my school project. My shooting logic and most of the systems are taken from this tutorial video: https://www.youtube.com/watch?v=P6kJq2n8DZA&list=PLfwUjqoSCep2yrUe1ojMARqBn8LzcUEMf&index=5&ab_channel=SmartPoly I would gladly appreciate some help from the community, thanks.

Hey @ThePortalo! Welcome to the forums!

One thing you could do: Have some variable Integers on your GameInstance labeled “Headshot Count”, and “Shots fired”.

When the player shoots, use "Get GameInstance → cast to GameInstance(whatever your gameinstance is), Set Shots Fired to “Shots Fired + 1”.

When the player gets a head shot, wherever the code is that confirms that, use "Get GameInstance → cast to GameInstance(whatever your gameinstance is), Set Headshot Count to “*Headshot Count + 1”.

Finally, you can use Get GameInstance + cast to Game Instance to get those variables, so you could do “Headshot Count / Shots fired” to get your percentage or any other stats that could use those numbers! Just make sure to use division, not the “%” node, as that means “Modulo”, not percent. :slight_smile:
Hope that helps!

3 Likes

Thanks for the answer @Mind-Brain, I’m gonna try it tomorrow. Henceforward, how can I make it appear at the end of the level? My game has 6 levels and it needs to reset on every level. At the end of every level I’m gonna have the time of the completion and the accuracy procentage. Thanks again.

On your level Blueprints, on Begin Play, you can Get Game Instance, cast to your game instance, then SET both of those values to 0.

GameInstance values reset to default on game close, it’s for temporary values.

At any time, anyWHERE, you can get those values using Get Game Instance, and casting to your current game instance’s class. :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.