How Can I Stop My Game From Lagging?

Hello, right now I am trying to make a packaged version of my game to send to some friends for play testing but I have run into a major issue. My game has a character that can pick up, drop and throw objects as well as aim where the object will be thrown. For some reason in the build of my game, when I try to change the aim or throw the object, the game will freeze and then resume sometime later with the object on the ground in front of the character. I have seen it lag slightly while testing in the editor but never freeze. All of the assets I am using are actors already in unreal, except for the art for one of the characters. I think the issue may have to do with poor optimization of the code but I don’t know enough about unreal blueprints to diagnose it myself.

Here is the code for the pick up/drop mechanic. I don’t think this is causing issues but I thought I’d include it just in case.

Here is the code for aiming and throwing. I think this code is what is causing the most issues. The idea is that when the player holds the throw button they can see what path the object will follow. If there is a way to do this that is less taxing for the game please let me know.

Here is the code for changing the distance/arch of the throw.

If anyone has thoughts on what could be causing the game to lag and how to fix it, or if you need more info please let me know.

Forgot to mention but I don’t think my computer is a part the problem. I’ve never had issues running high end games or other unreal projects.

Why are you using a for loop there? You can just use the Event Actor Begin Overlap node in the item’s or the player character’s blueprint, and check if the other actor is the player or the tagged actor. Don’t perform this in both blueprints btw, I just wanned to explain how you can do it in both ways respectively.

I’m just using a for loop because that’s what the tutorial I found had. I might try an overlap event if I have the time to test it.