How to make a boundary that slows the player down to a stop?

I want to stop my player but not immediately. My player can fly and I am trying to put a ceiling on how high the player can fly but I want it to be a gradual stop rather than immediate. Anyone got ideas? Ive already tried applying force in the opposite direction but it makes the player go slightly up and down repeatedly rather than stop at a certain height.

My player can fly

The precise method would depend on how you’re moving the pawn.

Check the distance to the ground / ground plane and map range this value onto the player’s ability to gain Z. Engage this rubber band only once the player has reached a predetermined altitude.


If you find the above bit unclear, consider showing your climbing script - this would make it easier to suggest something more tangible.

doesnt that method bring the player to an immediate stop? fyi my character uses add force to fly

right now the method i have in mind is to apply force in the opposite direction and when velocity = 0 set z to current height until the flying button is released. any better solution than this?

You could, above that height, Make it so that all the parts of the code that Add Force to your flying pawn cannot add any more in the positive Z direction (break the vector, overwrite the Z with negative of the difference between the height of the pawn and the ceiling height, but keep the other vectors the same, before it goes into any AddForce node).

doesnt that method bring the player to
an immediate stop?

No, the result of the map range node would reduce the climb speed gradually.

So how do you do it, you get forward vector and apply force?

I think ive tried that method before and I end up with yo yo up and down effect as the code is trying set player at the correct height. I’m gonna try if my previous idea works.

I apply force to +z. I tried map range and it doesnt graduate ease in etc. I thought at first that node could work but that only works on certain things like moving a character and reducing the scale value on the axis. Have I made a bad design decision using apply force instead of using the flying movement?

I have the option of using my hacky method or redesigning the flying mechanic. I guess I’ll see if my hacky method works first.

In that case then above a certain height then do like I said, but zero out the Z component of the force, and instead InterpTo on the Z location until it matches the height, leaving the other locations components the same.

Have I made a bad design decision
using apply force instead of using the
flying movement?

Not necessarily, if you want physics based movement, that’s the way to go. I’ll have a look at it if I find some spare time.

Have you tried physics thruster for movement? They’re equally difficult to balance right :]

i think the way ive went is correct because if i try to use flying movement, i will need to use friction to slow down and that will apply in all directions which will mess up my game. I’m just gonna go with my hacky method, should be fine.

Another idea is to use the set linear velocity node, but keep the X and Y components the same as the current linear velocity, just set the Z to 0 unless the pawn is moving downward.

This is what I meant originally:

Image from Gyazo


With this, if I just hold U, the ship will hover at max altitude. This can be improved, surely.
Let me know if you run into any snags, it was put together rather hastily :]

edit: don’t know how I managed to spell climb with a p, I’d like to blame fat fingers but that’s a stretch…

morning edit2: forgot to clarify; this dampener kicks in at altitude between 1500-2000 and gradually reduces your ability to gain Z by multiplying it by the desired/current traverse vector’s component. You could, of course, tighten it and tweak the settings a bit. Perhaps it will at least give you an alternative in case you can’t get your method to work.

yeah i’ll set the velocity to 0 when it reaches 0. I was gona set location to current location but setting velocity is simpler. thanks.

I see what you did there. I did something similar which was when reaching certain height in map range, the map range then dials down the force directly, so when for example when z 1000-1500 set force to current force - 0. Much simpler. I didnt like this method until I figured out I could stick velocity at 0 when velocity = 0 so that it doesnt yo yo. Then when flying button is release, velocity is released. This time though, im gonna apply force in the opposite direction rather than mess with my players flying force