# Add framerate independent force to character

**URL:** <https://forums.unrealengine.com/t/add-framerate-independent-force-to-character/487460>\
**Category:** Character & Animation\
**Tags:** force, framerate, unreal-engine, question\
**Created:** [August 15, 2021, 12:22pm UTC](https://forums.unrealengine.com/t/add-framerate-independent-force-to-character/487460 "2021-08-15T12:22:01Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zssork](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zssork/32/629783_2.png) [@Zssork](https://forums.unrealengine.com/u/Zssork)\
**Post date:** [August 15, 2021, 12:22pm UTC](https://forums.unrealengine.com/t/add-framerate-independent-force-to-character/487460/1 "2021-08-15T12:22:01Z")

</div>

I am so confused. I want to apply forces to my character but not as movement input but more like a **dash ability**. If i use **AddForce** of the **UCharacterMovementComponent** it is not frame independent. I get different results with different frame rates. I also tried **AddImpulse** but thats also creating different results with different frame rates (even when multiplying with DeltaTime) … im so confused. Im doing nothing more than calling the **AddForce** with the same Vector.

 ![346366-untitled.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/f/5/7f56bcc23544285ba2e924cafe34a3002764fbc1.png)

i have something like this but in c++

The **distance the character traveles** after pressing **M** is different depending on the framerate … i tested with **120** and **30** and the difference is like 20% or something like that.

My end goal is to have this working with a timeline so i can have a big force at the beginning and decrease over time but it isnt even working like this with a constant force vector.

* * *

**Solution:** Set the GroundFriction of the CharacterMovementComponent to 0

---

<div class="post-metadata">

**Author:** ![Kehel18](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kehel18](https://forums.unrealengine.com/u/Kehel18)\
**Post date:** [August 15, 2021, 3:32pm UTC](https://forums.unrealengine.com/t/add-framerate-independent-force-to-character/487460/2 "2021-08-15T15:32:31Z")

</div>

Hello! You can call AddForce with Vector \* DeltaTime to deal with different frame rates.

---

<div class="post-metadata">

**Author:** ![Zssork](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zssork/32/629783_2.png) [@Zssork](https://forums.unrealengine.com/u/Zssork)\
**Post date:** [August 15, 2021, 6:00pm UTC](https://forums.unrealengine.com/t/add-framerate-independent-force-to-character/487460/3 "2021-08-15T18:00:35Z")

</div>

yes i tried that … in the description of addForce it says it would be scaled to timeframe but it isnt working either way. I always get a different distance traveled

---

<div class="post-metadata">

**Author:** ![jwatte](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jwatte/32/744941_2.png) [@jwatte](https://forums.unrealengine.com/u/jwatte)\
**Post date:** [August 16, 2021, 2:28am UTC](https://forums.unrealengine.com/t/add-framerate-independent-force-to-character/487460/4 "2021-08-16T02:28:09Z")

</div>

For single-step inputs, you should not multiply by DeltaTime for AddForce, you should _divide_ by DeltaTime.  
The reason is that the impulse (acceleration) is defined as force times time.  
The force you add will be applied over the given DeltaTime. Thus, if you want a specific impulse to be applied over one time step, you need to divide the magnitude of that impulse by the step deltatime.

However, in the setup you post a screen shot of, you are applying the force over some amount of time.  
That amount of time is pretty long – looks like half a second? This is going to be 15 frames at 30 fps, or 30 frames at 60 fps. That should be plenty enough to even out differences in force, somewhat – if your frame rate is not perfectly even, whatever frame goes at the “end” if your input sequence will still get the full force, but will last for some time slightly above the desired 0.5 seconds.

You can improve this behavior by setting the maximum step time to something small, and let physics step more than once during an integration. That still doesn’t quite help with the “half steps” problem – in fact, Unreal just doesn’t have a good solution for that, as it doesn’t yet have a fixed frame rate. (This is a feature they promise for Chaos in UE5, so we’ll see if that shows up!)

Another option is to add this “dash” feature into your simulator itself, and add it as an additional position or velocity boost, rather than a force boost; at that point, you can control the exact shape of how much you add by moving along a curve you design. Record position or velocity when you start, and apply the difference between “current desired boost” and “current actual value” each frame while the boost lasts. You may get more control this way.

---

<div class="post-metadata">

**Author:** ![Zssork](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zssork/32/629783_2.png) [@Zssork](https://forums.unrealengine.com/u/Zssork)\
**Post date:** [August 16, 2021, 4:36pm UTC](https://forums.unrealengine.com/t/add-framerate-independent-force-to-character/487460/5 "2021-08-16T16:36:20Z")

</div>

Thank you for your answer. I did some testing with AddForce/AddImpulse and DeltaTime and here are my results. I used the BP code From above with a blank third person project. The start position is always the exact same but the distance travels is depentent on the framerate. And it is not acceptable … the difference is huge … to me that dose not seem like is only a issue with the last frame.

 ![346452-wtf.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/d/6/5d61367867b1ffc7ff0677a75b9b4fba3ec6f15a.jpeg)

(right click and open in new tab for better quality)

The only thing that is working is if i use AddInputVector - then the distance is the same. But i dont want to use that because i dont want to change the movement parameters like max movement speed and so on when executing the dash.

What do you mean with a custom simulator. Do you have a documentation page or something where i can look closer into this?

---

<div class="post-metadata">

**Author:** ![jwatte](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jwatte/32/744941_2.png) [@jwatte](https://forums.unrealengine.com/u/jwatte)\
**Post date:** [August 16, 2021, 10:57pm UTC](https://forums.unrealengine.com/t/add-framerate-independent-force-to-character/487460/6 "2021-08-16T22:57:40Z")

</div>

A first order integrator will never be robust to frame rate differences.  
The character movement component does a bunch of work to make the “add input” function be similar across frame rates and networks.  
A “custom simulator” means implementing a custom movement mode, which is best read about in the C++ source (this requires C++.)

Honestly, it sounds like temporarily increasing the max movement speed and using add input will be the best option for your use case!

---

<div class="post-metadata">

**Author:** ![Zssork](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zssork/32/629783_2.png) [@Zssork](https://forums.unrealengine.com/u/Zssork)\
**Post date:** [August 17, 2021, 7:32am UTC](https://forums.unrealengine.com/t/add-framerate-independent-force-to-character/487460/7 "2021-08-17T07:32:00Z")

</div>

ok thank you

---

<div class="post-metadata">

**Author:** ![Zssork](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zssork/32/629783_2.png) [@Zssork](https://forums.unrealengine.com/u/Zssork)\
**Post date:** [August 21, 2021, 1:00pm UTC](https://forums.unrealengine.com/t/add-framerate-independent-force-to-character/487460/8 "2021-08-21T13:00:56Z")

</div>

I got the solution … the broblem was not the AddForce or AddImpulse but the character movement configutation. When in Walking mode the GroundFriction gets applied and that is for some reason not framerate independent together with a custom force. So i just set the GroundFriction to 0 for the duration of my dash and everything works fine.

---

<div class="post-metadata">

**Author:** ![imtrobin2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@imtrobin2](https://forums.unrealengine.com/u/imtrobin2)\
**Post date:** [February 15, 2024, 12:52pm UTC](https://forums.unrealengine.com/t/add-framerate-independent-force-to-character/487460/9 "2024-02-15T12:52:06Z")

</div>

That’s not really a good workaround.

---

<div class="post-metadata">

**Author:** ![Zssork](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zssork/32/629783_2.png) [@Zssork](https://forums.unrealengine.com/u/Zssork)\
**Post date:** [February 20, 2024, 1:12pm UTC](https://forums.unrealengine.com/t/add-framerate-independent-force-to-character/487460/10 "2024-02-20T13:12:02Z")

</div>

@imtrobin2 feel free to suggest another solution for this issue. At the time i was glad i found this fix for my framerate independance issues. Honestly this could also verry well be a bug … i agree i should not have to set GroundFriction to 0 for framerate independance but this was the only fix i found at the time

---

<div class="post-metadata">

**Author:** ![imtrobin2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@imtrobin2](https://forums.unrealengine.com/u/imtrobin2)\
**Post date:** [February 20, 2024, 3:38pm UTC](https://forums.unrealengine.com/t/add-framerate-independent-force-to-character/487460/11 "2024-02-20T15:38:11Z")

</div>

I don’t have another solution, sadly but I do plan to use ground friction on surfaces, so this workaround is not great.

---

<div class="post-metadata">

**Author:** ![jacoboren](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jacoboren/32/572257_2.png) [@jacoboren](https://forums.unrealengine.com/u/jacoboren)\
**Post date:** [May 21, 2024, 6:27pm UTC](https://forums.unrealengine.com/t/add-framerate-independent-force-to-character/487460/12 "2024-05-21T18:27:44Z")

</div>

can you show how yo do that please. i dont find this option

---

<div class="post-metadata">

**Author:** ![Zssork](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zssork/32/629783_2.png) [@Zssork](https://forums.unrealengine.com/u/Zssork)\
**Post date:** [May 23, 2024, 7:51pm UTC](https://forums.unrealengine.com/t/add-framerate-independent-force-to-character/487460/13 "2024-05-23T19:51:11Z")

</div>

[GroundFriction](https://docs.unrealengine.com/4.26/en-US/API/Runtime/Engine/GameFramework/UCharacterMovementComponent/GroundFriction/) is a property of the movement component.

I did something like this:

```auto
void AMyPlayerCharacter::StartAbilityMotion() {
	if (GetCharacterMovement()->GroundFriction != 0) {
		DefaultGroundFriction = GetCharacterMovement()->GroundFriction;
		GetCharacterMovement()->GroundFriction = 0;
	}
}

void AMyPlayerCharacter::StopAbilityMotion() {
	GetCharacterMovement()->GroundFriction = DefaultGroundFriction;
}

```
