Issue with Setting player velocity being framerate independent

Basically I’m working on a sliding mechanic but I noticed that on higher or lower framerates, you slide further or less.

Video showcasing what’s happening: https://youtu.be/-yE_aDHxllE
Screenshot of my blueprint setup: Imgur: The magic of the Internet

Just to provide a bit of context for the video and screenshots:
So in the video, the behavior at 60fps is what I expect to normally happen. But when I set my max to 144 and then slide, I go further than expected. Then when I reduce the framerate, my slide barely makes my player travel.

For the blueprint: Before the slide key is hit, the player velocity is stored. Then on the event for crouching, it simply sets the bool to true so the tick can pass through set the player velocity so it slows down gradually

So again: I’m really not sure what the issue could be here. The actual interp node is taking in the deltaTime, yet the sliding is still being impacted by the framerate.

I’ve tried timelines aswell before posting this and the result is the same: The sliding is affected by framerate. If anyone could point me in the right direction on what I could change I’d really appreciate it. I’m guessing it might be the actual SetVelocity node if both the timeline and interp aren’t behaving correctly but I’m not sure

1 Like

The ‘current’ parameter of a vinterp needs to be sampled in realtime, that’s why it’s called ‘current’ :slight_smile:

In this case the actual character xy velocity.

I think that should help?

Timelines are not affected by framerate, that’s the why they exist.

Setting cube height at 120fps

120fps

10fps

10fps

Ahhh thank you so much. I can’t believe I didn’t figure that out earlier.

1 Like

:+1:

Pardon me for bringing this topic up again but I’m a bit of a newbie to unreal engine so I’m trying my best to learn these concepts lol.

So the “vectorInterpTo” node did work for almost every other thing I tested it on. Like moving platforms and objects, but when I tried applying it to this sliding mechanic I realized that the ground friction ruins the interpolation. Since we’re sampling the current speed in real-time for the node, when my player hits the ground and the slide begins my velocity automatically hits zero because of the friction. Is there any workaround to this?

I tested timelines a bit more but I’m not sure if I’m completely just messing something up but they’re not framerate independent either?


Firstly just by plugging in the vector


and then by multiplying the velocity right before sliding and then using the timeline to slowly multiply by zero so it cancels out.

Why is it that on lower frames I slide less and on higher frames I slide further? You can try this out yourself too just with any first or third person character and then just setting the velocity. It’s a completely different experience on higher or lower framerates

It would be more like this

I just tried it and that seems to be dependant on framerate too?

Although it’s a bit more stable than multiplication since on lower framerates I still slide somewhat accurately but on higher framerates I still go much further?

Again pardon me for asking about timelines all of a sudden when the original point of this topic was the interpTo node, but Like I said: the specific VectorInterpTo node worked perfectly for other things, but since the ground has friction it just doesn’t work for that since my player instantly stops lol.

So I’m trying to resort to timelines or any other way that would give me a similar result.

1 Like

Just to be clear, that ‘new track 1’ has to go from 0 to 1 over the life of the TL.

Yep i’ve tried both ways


There’s still a difference on higher/lower framerates in how far my player slides

Seriously, try this out yourself, I can’t understand why the timeline works PERFECTLY for everything else but just this, it doesn’t work for this sliding mechanic

1 Like

Right, then you need to decide how far you want them to slide, and do it that way. Just side-step the physics…

I’m sure you can appreciate devs spend a long time getting this sort of thing right.

It’s because you’re letting the physics interfere.

1 Like

Ah alright this works on all framerates I’ve tested it out on. Thanks for informing me about the physics aswell I wasn’t too sure about that.

Only problem with this method of sliding is that your player can slide through walls. That’s why I initially went with adding velocity.

So with the physics interfering with DeltaTime then, is there nothing I can do? How do other games go about adding sliding mechanics? A lot of platformer games that have been made on unreal engine manage to deal with this issue so I’m not sure how they get a smooth sliding experience even on lower frames?

I was testing out multiplying DeltaTime by the actual timeline result and then trying to add velocity like that.

This is probably the closest thing I have to accurate sliding movement that works with velocity and doesn’t pass you through the walls.

I guess besides this, my other alternative could be that when the player slides, the gravity and physics simulations are turned off and I could make an entire system around that.

Well anyways thank you a LOT for bearing with me. I learned mostly off youtube so I never even knew that there was a physics involvement aswell lol.

Like I say, lots to consider :slight_smile:

You’ll need to do a line trace and stop the slide, that’s one way.

Physics doesn’t change delta, but your original code wasn’t letting the timeline do the work. If you let physics take any control, you will get unpredictability.

Nope, back to the dark part of the woods :slight_smile:

A lerp just needs 0-1, using delta time here doesn’t mean anything.

Yeah I mis-worded that. The world environment interferes with it and it’s unpredictable and all that.

Anyways my understanding is a lot better so I’ll work on this using trace scans and figure something cool out. Seriously though thanks a ton. You’re a legend to this community. Checked your profile earlier and how many posts you respond to, you’ve saved thousands of people from headaches including me. :heart:

1 Like

You’re welcome :slight_smile:

I would choose a few well known games with slide mechanics in, and see if you can find the devs talking about how they implemented it.

But I’m pretty sure they wrote their own character, so everything is under control then.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.