Smoothly push player while not moving?

Hello,

Using the Character Movement component, if you actively move a character up against a moving obstacle (such as a block that shifts left and right on a spline) it will smoothly push the player out upon overlap. However, if the moving obstacle collides with the player while he isn’t applying any movement, it will jerkily teleport him out, which feels terrible and looks very unprofessional.

Is there a way to fix this? I’d like the same smoothness regardless of what movement state the player happens to be in. I thought “continuous collision detection” would, but it did not seem to. I noticed that when standing on an obstacle, the player smoothly is pushed. That’s what I’d like, just with horizontal and rotation (object spins and collides with player) interactions.

2 Likes

Nobody knows how to fix this? It seems like it would be a simple toggle somewhere I must have missed.

@EntrpriseCustomr I’ll go through those options again and see if I missed anything, but I don’t think I did. A volume that moves with the object and adds a *very *small force, like 1 unit, was something I considered, but I haven’t tested it much yet.

About the timer issue, no I never found a definitive fix. But I found a “good enough” solution that works for 10 and up fps. I subtract deltatime from the overall length of the timer when setting it. This makes it nearly the same “distance” every time. Not sure how this would perform with fluctuating framerate, but for now it seems fine.

Here’s a better example of what I’m trying to fix:

smooth: smooth
jagged: jagged

The second video only happens when you aren’t applying input to the player. Sometimes it might even launch you off the ground a little bit. I assume it only uses “sweep” function when the player is moving, and resorts to some coarse “push-out” when you’re standing still. Most likely for performance reasons?

You could play with lowering Max Depenetration Velocity on the colliders; the setting dictates the rate at which intersecting geometry is ejected and is quite high by default. Not sure whether that will help with the movement component since it lives in its own dimension between physics and reality :|. But it might be worth experimenting with since it’s just a couple of clicks:

A depenetration value of just 5.0 will produce this lazy behaviour for example: https://i.gyazo.com/26bfa0d36d7273a6…e78b4125c7.mp4

This will have no effect if you’re not simulating physics.

Seems it doesn’t really work with moving objects. Here it is with a low value: GvAYCLdSs1

Higher values than default also didn’t cause any change to how it was working from the start. Ideally i’d like to be able to have “sweep” working constantly. Which is what I thought CCD did. I wonder if there is no solution in the editor, that duplicating the Character Movement component itself and changing the C++ code is possible?

I see, I’m using the character movement component for player movement, and the shifting block itself is just an actor that moves on a spline track. Currently nothing is simulating actual physics using that checkbox in the properties of objects.

The atrocious behaviour you’ve demonstrated was easy to replicate. I’ll play it with it and see if I get anything working any better.

@Everynone thank you, I really appreciate the help.

It’s probably going to be the usage of MoveAlongWall in the CMC that allows the smooth movement.

When you collide with the wall, the standard collision adjustment will happen, and then the MoveAlongWall runs to push you along the wall.

When you’re stood still, just the normal collision adjustment will happen, which means jank

Sweeping and Adding Movement Input in the opposite direction seems to work OK:

2e4c6246b180069b642a1764633d8c3f4af419d8.jpeg
https://forums.unrealengine.com/core/image/gif;base64

vid: https://i.gyazo.com/e2d3daa7efa8ea04…d9cc586495.mp4

But since we’re sweeping, the moving mesh will actually stop if its obstacle cannot be moved out of the way - as in: you’re still applying movement. Since sweep is exposed, perhaps you can tell the obstacle to sweep only if no Input is applied. An interface could pipe in the data into the actor.

This is an interesting approach I hadn’t thought of. I’ll look into this, and similar. Maybe if I’m just going to use cubes I could also do a bounding box push-out of sorts, that snaps the capsule to the respective edges on overlap, instead of further out than it needs to be.

Thank you for the explanation/tips. I think I should be able to get something working, even if it requires me to edit the C++ code of the movement component. I’ve been needing an excuse to look into those for a while now anyways, lol. I will also keep in mind to link videos directly in the future.

Ah, figured there would be 2 methods like this. Do you know if it’s at all possible to just make a custom component that defaults to “MoveAlongWall” at all times? I might be able to optimize a bit by only turning it on while within an actor’s bounding box etc.

Thanks again everyone for all the responses.

You can definitely use a custom CMC.

If you want to go that route, I might suggest just extending the stood still code to more robustly use MoveAlongWall

Reviving this thread because I came up with a solution:

-set moving object location with SWEEP enabled
-if sweep hit anything, add offset to hit object
-set location again without sweeping

images here:


video here: 3FKKE5KRSc

It currently has a limitation I’m attempting to work around, which is that even if the player is standing on top of the object, the sweep detects it and causes the player to get thrown off if it has a movement component that supports objects beneath it, like the CharacterMovementComponent. Another potential downside is that since the “set location” sweep doesn’t seem to return an array of hit actors, it might not support multiple collisions at once. A simple shape multi-trace would fix that specific issue, but then you wouldn’t be able to use complex geometry for the platforms.

If anyone has ideas on how to fix the problem of being on top of the platform, please share!

Hopefully, you already solved this but for anybody finding this thread on a search: You can check the Characters “Base” to find out what actor it’s stood on and do a comparison.

What do you mean with Charecters “Base”? I am in the same situation

Bumping this because I have a very similar problem. What causes the effect in this video? - #29 by logic_looper

The problem is that the character is not calculating collision unless it’s moving,
this is a temporary solution u can use I will edit it once I find a better one.(put this in the tick function of your character )

2 Likes

I’m fascinated by your solution…with a jpg/png showing 4 simple nodes you have just about solved a problem I’ve had for months. Thread here.

So let me sum this up… for awhile now I and a few others here have noticed a problem when it comes to the player being “pushed” by a wall or something. Unless the push occurs in the Z (up and down) the player is jerked and not pushed smoothly, for a video demonstration look in the thread I linked. This was ultimately proven to me to be the SHAPE of the capsule component and the way UE does collision.

I imagined there was a simple solution and perhaps you have almost found it. I notice your solution ignores the Z (since pushing in the Z doesnt seem to matter.)

In the first sentence, notice how I said “about solved” the issue…unfortunately I have found a small problem, that perhaps you or someone else can figure out.

I will make a quick video and show you what the problem is.

In this video…when the game starts you will see 3 moving platforms each moving basically the same speed. Mover 01 in the X moving toward the camera, Mover 2 in the Z going from down to up, and Mover 03 going from left to right.

The movers are simply actor BP’s with a cube sized / scaled appropriately to represent a wall. Then dragged into the world. Simple logic to move them.

HERE is the problem! I see smooth pushing from the left to right wall, (and surely the vertical platform) BUT, the wall coming from the background toward the camera there is a strange “torqued” sliding going on. I hope you can figure out what is causing that. Because your solution here is one of the simplest I have seen and look forward to using it!

I just turned off sweep on the node on the left and the “torqued slide” (good name?) changed from the Y + moving platform to the X- platform.

I’m not sure I understand exactly how this solves the pushing issue but I’m not complaining…seems it just cancels each other out.

If I turn both sweeps off then nothing happens and its back to herky jerky. If I toggle one or the other on or off I can effect either X or Y.

Perhaps @ Everynone can solve this simple problem?

bump bump…anyone know what is truly going on here and why does it partially “work” for the problem.