Download

How can I make simple player pawn accelerate?

Hey guys! I’m trying to add movement to a simple tank (player pawn) and I have little problem.

Actor is built from two boxes - hull and turret (no animations). Left gamepad stick controlls the whole actor, right stick controlls turret and the camera. I made all the physics and collisions, everything works fine except acceleration.

First I tried to do it with Finterp, to make the tank reach max speed over few seconds. It worked quite well but - because of delta time - acceleration time is different everytime (it depends on fps count).
Then I made a function to increase variable value when the stick is tilted in desired direction. At first it worked well too but - because of delta location in AddActorLocalOffset node - acceleration behaved the same way as with Finterp.

Do anyone know solution to make movement like this and keep the acceleration time the same, independently from fps count? I appreciate any help!

There is Lerp and then there are other lerping functions check them all until you hit the right one. FConstantInterp or some like that… if you can’t find it tell me.

Thanks for the tip! First I tried normal lerp and combined it with a timeline (which was changing speed over time while gamepad stick was tilted) but it was causing some problems with collisions (pawn was clipping through the landscape and falling down). Then I gave “FInterp to Constant” a chance, as you mentioned, and few moments later I found out, that I was multiplying speed by delta seconds in the wrong place. Now acceleration works like a charm. Thank you very much for getting me on the right track! :slight_smile:

Here’s how the bp looks like:

OK yeah well there’s always a way to flank.