Restart Level on Speed 0?

Hi,

I’d like to restart the level IF the player’s speed becomes 0.
Basically, if the player runs into an obstacle that prevents them from moving any further,
I want them to start from the beginning of the level.

I know I can set it to restart when a certain speed is reached, but what if I want the restart level event to initiate when the speed becomes 0, from an already 1+ number while moving forward?

This may not answering your question, but I personaly would do it with the OnComponentBeginOverlap-Event. If this Event fires you can set your level to restart.

If you realy want it to be driven by the Speed you have to Check every Tick, if it is 0.

There are two ways to do this. If you really want any event in which the player stops moving and are using a character (not a pawn) then you can check for the characters velocity (which is part of the character movement component every character owns). You can get it via the same as well. This… well it represents your velocity. If that is below a certain number you can just say he isn’t moving anymore and restart the level.

However sometimes you might want to just pause the movement for a bit which would trigger this as well. A great solution could be just detecting collisions (from the actor you hit) via an interface. On event hit → if other actor implements interface → kill. Like this you can chose yourself which obstacles actually kill your character.

I hope this helps.

Cheers :slight_smile:

Erasio, if I determine that my “CUBE” obstacles kill my character, I only want to kill him if he runs into them. I still want him to be able to walk on top of them.

Sometimes, even if he hits into them and gets stuck, simply jumping can get
him on top of the cube. Other cubes, it cannot.

Well a combination of both of those things are possible as well. On hit call an interface event for your character. Inside of your character you then can check if your velocity is low or even exactly 0 and if that is the case destroy your character.

Or just do the velocity thing. That will certainly work as well. I’m just throwing around with ideas of how it would be possible to do it because I have no idea what exactly your usecase is. Just decide yourself what exactly it should do. If none of my suggestions fits those requirements ask again with a more detailed explanation and I’ll see what I can come up with :wink: