How to replicate movement physics of FZero X?

Hello, I am trying to replicate the movement physics on a ship shaped Pawn that moves by adding impulses on it. The problem is that I cannot cancel the lateral displacement that occurs when turning the ship in another direction (accumulated momentum in forwardVector), since it behaves as if it were a car drifting.
Can somebody help me?
A greeting.

hi Turok, welcome! (taking a break from dinosaur hunting and whatnot?) :slight_smile:

this one had me googling for ages, but here is the solution I came to… first thing, get the world linear velocity… inverse transform it to local velocity… now you can print out values for X (forward) Y (sideways) and Z (upwards). Now that you know the local velocity of your pawn, add a magnitude (enough to cancel or reduce the force), then transform it back to world space to add force in the appropriate direction to counteract it.

It’s ok to break the local vector, but just be careful not to break the local to world vector… because it has been transformed.

First of all thank you very much for the answer, I think it may be the perfect solution but there are many things that I do not understand because I have been with Unreal for a short time hehe. Yes, I’m taking a break from hunting dinosaurs hahaha :slight_smile:

I wanted to ask you where the variables I have seen in the blueprints (Pawn Transform MMT, PawnVelocity Linear Velocity, Pawn Forward Vector MMT (ForwardVector of the Pawn? And ControlForward) come from that I don’t know how to initialize them, or if you could capture those parts since I’m a little lost.

If I have not misunderstood, I have to apply an opposite force to counteract the lateral impulse, but I am not very clear.

I put a screenshot of how I did it, in case it would help because I’m still not doing it right.
Image 1 is how I had it, and 2 how I left it because I don’t know how to continue hehe. This function runs on a Timer every 0.1 seconds to add more momentum.

In advance thank you very much again, greetings!

Yes, you are right. I got those variables in an earlier part of the BP… and the force that is added counteracts (almost) exactly the sideways slip (in pitch and yaw) of the actor, giving it (the illusion) traction. You can vary the multiplier to suit the amount of slip (if any) that you’d like. Print out the local velocity and set the multiplier (depends on your mass and use velocity setting), large enough so that it’s close to zero.

For the moment, you can use GetPlayerTransform and GetLinearVelocity and GetActorForwardVector

Until you have it working, for simplicity, I wouldn’t use a Timer quite yet…

I’d set yours up exactly like mine, using AddForce (not AddImpulse or AddForceAtLocation)…

Hello!
Thanks again for the help, i will keep testing with the force and impulse to see if i get what i want hehe

I mark the first answer as correct because there is the solution there, you just have to know how to apply it (I don’t know at the moment).

A greeting! :slight_smile:

greetings! :slight_smile: the exact way you do it will depend on your Actor/Pawn/Character setup… physics etc… but here is hopefully a good start.

It’s really useful to understand the difference between world and local space