Download

Beginner advice about collision responses

Hey all,

I hope I’m in the right forum. I’m trying to build a primitive platformer with some very basic collision functionality: a trigger volume that kills me and a trigger volume that displays a simple “You win!” message before resetting the level. I figured out how to make a kill volume that restarted the level, but that resulted in the “game” freezing on restart. I managed to get around that by turning the kill to on contact instead of on overlap, but I am totally lost on how to design the “victory condition” blueprint without running into the same problem.

Thanks for the help,

Jason

You can consider both “Dead” and “You win” as states the player can possibly be in. Neither can be true at the same time and there is also an intermediate state that is simply “Playing” or “Alive”. These states can easily be represented in an Enumeration on the Player.

Once you have the states setup on the Player, the volumes only need to modify the Enums current value to whatever value applies to them. So the Kill Volume will change the Players state to “Dead” when the player moves over it. Similarly the Victory Volume will change the players state to “You Win”.

In your GameMode or Level Blueprint (more appropriate in GameMode Class), you can check what the current state of your Players Enum is to decide what to do. If the Enums value is “Playing” or “Alive”, then do nothing as they have not achieved any higher state. If it changes to “Dead” then you can reset the level. If it changes to “You win” then display your message and apply any scoring logic and reset the level again.

This is a simple implementation of a Finite State Machine, an important concept and one i recommend you read further into.

Just remember, once you reset the level, you will need to make sure that the Players State Enum is returned to its original condition.

Good luck.