How do I make movement less choppy?

Hello! Working on a game where you move in a large vehicle and while the code works, the movement is INCREDIBLY choppy, is there a smoother method to do this?

What calls MoveCalc?


You could instead call:

image

But what you’re showing should not be choppy to start with if called on Tick / often enough. Also, since this is a vehicle, perhaps you should consider a movement component. UE supports actual vehicles, too. And physics as well. Too many options to move stuff.

Depends on what is needed.

Just a timer by function that calls every .1 second as this appeared to be the most common result when looking up how to make something move

Also, as for the vehicle itself it operates on buttons within the vehicle itself, you never see the outside of the vehicle (closest comparison would be the submarine in Iron Lung except this one moves around the map)

Call this in the Tick Event so that you set the location on every frame. The interval of 0.1 is relatively large compared to 0.016 (for 60 fps) for the Tick event. Additionally, you should multiply the speed by the time delta. Make sure to set the Sweep parameter to true so that your actor does not go through obstacles.

That’s 10 updates per second. It’s going to be as fluid as 10fps. You want something updated every frame? Do so.

There’s more than one problem with this.

First, if you teleport the object ten times a second, it will move at 10 fps. This is not going to look great.

Also, if you teleport the object, it won’t run physics for things like bumping into rocks, running up ramps, etc.

Finally, your “speed” movement isn’t multiplied by the delta time of the time step, so it will move faster at a higher tick rate, for the same speed.

So, to build a vehicle, there are three general approaches: Use Chaos vehicles, or roll your own physical simulation, or just force the vehicle to move along a track like a train or cable car.

I recommend using the Chaos vehicle setup if possible, because that already has gas/brake/steering/engine/gears all set up, and you can tech up your chassis and models in the editor.

If you want to roll your own, you should probably build it as a blueprint with a box collider for the chassis, and four cylinders for the wheels, and then some kind of physics constraints/springs to keep the wheels in the approximate right location – typically, these will spring up/down like McPherson struts, but be locked in the sideways movement axes. Then drive the vehicle by applying torques to the wheels to make them spin.

If you want a rail experience, it’s probably easier to just animate a timeline or spline for the vehicle to move on, and use the animation system of your choice to lock it to that spline.

In each case, the position update will happen every tick, either through the physics simulation system, or through the animation rendering system, and thus the movement will be smooth.

Thank you for the suggestions, though im umfaimiliar with a lot of the methods which would be the best option if I want the player to click buttons within the vehicle instead of just using wasd
the chaos thing sounds interesting but would the steps for modeling wheels and whatnot be necessary if the player never sees the outside of the vehicle while its moving, and would it work with the above constraint?

just adding another option that i didn’t see mentioned, but if its like a submarine i think using a pawn and floating pawn movement and using the Add Movement Input nodes would work fine. Very simple and with some simple lerp you can make it seem like its a complicated physics setup without actually being so.

Modeling the wheels is necessary for a reasonable simulation, even if the user doesn’t see them.
(You just don’t need to make them pretty if that’s the case! Unless there are reflective surfaces.)

Interacting using buttons, could be as easy as using the Widget Component to put a 2D UI panel in the 3D world that the user can click.

You will need to read up on some of these things (use the google for the appropriate keywords) to get there, but unfortunately I don’t know of any shortcut around that. It’s totally possible, though!

Thank you for the advice, ill look into it further and see what I can do with it