How to make a volume to slow down the player's velocity

Hi I am making a game where you a cube that is constantly moving forward . The goal is to get to the end of the level with out moving too slow.

Is there a easy way to slow down the velocity of the player?

1 Like

Sure, but it, kind of, depends on and how the player moves. How are you moving the cube forward atm?

I am using Impulse To move The cube

Makes sense. So how does the slow down volume work then?

  • you enter the volume and you lose some of your speed at once
  • or you keep losing speed the longer you’re inside
  • is it in a linear fashion or the longer you’re in, the more quickly it drains your velocity
  • what about the direction, what happens if you enter at an angle (is it even possible?)

See if you can shed some light on the above, and I’ll try to put something together in the meantime. Atm, the easiest method that comes to mind would be to have the volume also add the impulse to your ship, but in the opposite direction.

you enter the volume and you loose some of your speed at once and it doesn’t matter what direction you enter in, because I only care abut the speed of the X axis. I also like the idea losing speed the longer you’re inside. Can you put the answer in the answers an not the comments.

The most basic and robust setup would look like this, inside the trap actor:

It essentially takes your current velocity and applies a % impulse in the opposite direction. This is an actor with a box collision you can put anywhere in the level and it will only affect the class you cast to. You can expose that -.25 as a variable so you can edit the slow down magnitude of traps you place in the level. If you turn it into a positive value, it will give you a boost.

I also like the idea losing speed the
longer you’re inside.

This should be good enough to build on:

This takes away percentage of your speed every frame for as long as you’re in the volume. Similar to the above. This will not actually stop you in place as it works around percentages; you can instead deduct a fixed value rather than sampling the ship velocity - your design choice.

Image from Gyazo

Do tell if it helps at all and good luck!

1 Like

This has been a super helpful example which has solved a big problem I was having.

I wanted to have an effect similar to transitioning from walking into swimming where there is a slow down resistance when entering a volume, but due to the way the character movement component is made, I could not simply add a volume that gives the same resistive effect unless it switched the movement state to swimming.

The technique you showed above works well, and it seems to be working in multiplayer from my initial tests also!

Thanks heaps, as I was starting to feel like I would have to give up on a feature that slows down a character as they move through a volume.

So far working well for me :smiley: