Hello there. I would be really grateful if someone can help me on this. In my game which is TPS im using CharacterMovement to move my character with (AddMovementInput). Now im trying to create my own acceleration system because UE doesnt let me add any physical force on my character. In one of my Anim Montages i created a AnimNotifier which in it’s tick it set a variable called (ForceAcceleration = 100(exmple)) every frame. In my character code i set my character movement velocity to every frame :
LastUpdatedVelocity+ ForceAcceleration.
I also have a opposite force against my forceacceleration which move it toward 0 fps independently in player’s Tick.
But my issue is that character’s acceleration is different in different frame rates. How can i fix this? Thank you.
Whenever you use the addition or multiplcation of ‘constants’ with Tick, you will get this effect.
The solution, luckily, is simple. Every place you have a ‘constant’ ( ie, you’re adding 10 units etc ), just multiply that by GetWorldDeltaSeconds.
Basically, this is the amount of time the last frame took to run. So it you’re on a slow machine, it will be a bigger number, and it fixes your problem…
What I find best, is to think in real-world physics terms. A velocity would be distance / time. Where it gets confusing is you actually multiply your Delta Seconds by your distance because it is a fraction. For example, if your characters velocity is 100cm per second, to figure out the distance it moved that tick and get its final location at end of tick, you would take it’s velocity and multiply by deltaseconds, then add that to its current location to gts its new location at end of tick. Acceleration can get a bit more complicated because you actually end up calculating an average of the change in velocity. I had to google to find the equations I needed. I then made a library of physics function to do the conversions for me. for example, I have a spceship which has a max thrust of X Newtons, I multiply the user input (throttle) by the max thrust to get current thrust in newtons, knowing that Force = Mss*Acceleration you can derive an equation to get acceleration when Mass and Force are known. Once I have the Acceleration, I calculate my final Velocity and also calculate the displacement so I know the new location of my actor. Try googling “Acceleration from force” or “Displacement given Acceleration and Time” and other slike that to find the equations you need.
Thank you for the answer. I kind of understand how this physically works but my issue is there is no way to adjust the velocity of CharacterMovement fps indepenetly. the formula i found is like Vf= Vo+at to calculate the final velocity given my acceleration. but How do i correctly set this to character’s velocity?
Hello there. thank you for the answer. idk why when i replied but my reply still not here. My problem is even if i have the final velocity and acceleration using (Vf= Vo + at) idk how to apply it to characters movement velocity for it to be frame independent ?
setting the velocity in tick make it to be frame dependent. if frame is higher it catches more speed because adds more velocity per frame.
When doing your calculation, where T(Time) is in the calculation, you are getting Delta Seconds yes/no?
FinalVelocity = OriginalVelocity + (Acceleration*DeltaSeconds)
Maybe if you can explain your game setup and what you are trying to do, I can explain better how to maybe setup your physics system.
Thanks for your follow up . My game is a TPS boss fight game . For our evade mechanic i wanted to make it physic based so i can control how she moves and how much she slides till she stops . So in my evade animation i created a AnimNotifyState called (EvadeMove). in this notify state’s tick i add certain amount of vector (which is multiplied by Frame Delta Time) into a variable in my characters BP called EvadeAcceleration. so my intention is to have different acceleration vector for each moves like evade , push back so i can adjust how they decrease or increase. Now in my characters event tick i will decrease my EvadeAcceleration using a Spring Vector Lerp to give it that smooth sliding feeling and at the end set CharacterMovement Component velocity = velocity + evadeacceleration. but after all this the amount and speed of movement is not the same in different frame rates .
is it possible for you to continue this in discord ? because its very slow here . discord id : Mooltee#4055