Making my brake run in a loop without error

Im trying to make a mechanic for my marble racing game where you can brake to slow yourself rapidly to allow for tighter turns. Every time I try to test out the code I get a “Infinite loop” error. Is there any way I can work around this so it wont give me this error while still doing what I want it to do?


Here’s my code for braking

Hello, based on the reference image:

  • The InputAction should only be used to toggle the Boolean value.
  • There’s no need for the WhileLoop, I would do such checks OnTick.
  • You can connect the ReturnValue (Boolean) of the LineTraceByChannel directly to the Branch, there’s no need to check if it equals True.

Here’s an image for your reference:

Please keep in mind that this is just a suggestion based on the image reference you provided.

I hope it helps!

Ok, thanks, will this cause the game to lag? since in runs every tick.

Relying heavily on Event Tick can indeed affect your game’s performance, but not in this case as it’s just a simple line trace and it only runs when Brake is pressed. The only case where this might affect performance is if Trace Complex was set to True + the Actor was on top of a very complex mesh.

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