Turn around until facing other way of forward vector

I’m fooling around with a top down space sim. My spaceship flies around just as intended, but I want a little extra and I can’t seem to figure it out.

I can perfectly turn the ship around while still continuing on the “forward vector” when the thrusters are disengaged (like it would without gravity). Now I want my ship, when I press a button, to start turning around, away from my forward vector, until my ship is facing directly opposite of the movement. That way, when I engage my thrusters again, my ship will start to slow down and come to a complete stand still.

How can I get that forward vector and than tell the ship to start turning until it reached the opposite? Can I do this with blueprints?

First one question: are you using physics and inertia/physics thrusters to move and rotate, or you just update location and rotation of spaceship?

With physics and inertia whole thing is not simple, as you need to calculate thruster force and estimate when slow down and counteract current momentum.

For just rotating in 3d space, use interpto functions. Get forward vector of ship, normalize it (just in case), negate, then calculate rotations from negated vector.
And set rinterpto goal as new rotation of ship, interpto will handle slow/smooth rotation over time to desired goal.

This is what I got right now. I don’t know if it’s nice code, but it does what I want it to do (I’m not a coder, just experimenting right now).

For proper simulation you’d need Torque, account for angular momentum, write PIDs for thrusters and a lot of tweaking. Absolutely doable but not the easiest thing to set up. [HR][/HR]
Judging by what’s shown and how physics is overridden here, you might be after something more *arcady, *though; in which case do consider the following:

After pressing 1, we kill angular velocity and interpolate from current rotation to rotation whose X vector is opposite to our velocity vector. Once the rotations (almost 0.1) match, we close the gate - you’re now rotated opposite to where you were going. Not the forward vector, but the opposite direction than the current velocity, so firing a thruster will now bring you to a full stop with next to no drift. And this will work OK even if the traverse direction changes during rotation (perhaps you bump into something).

The additional InterpSpeed variable goes from 0 to *some value and *helps to mitigate how large the initial rotation interpolation steps are. Without this, we’d start rotation quite abruptly. You can test it out with flat values (try 0.5-5) or, better, use a curve reflecting how manoeuvrable this particular ship is.

vids: vid1, vid2, vid 3

I copied what you did there, and it does exactly what I had in mind, so thank you! I was close in my own tryouts, but at the same time far away. Could have taken ages. :slight_smile:

But could you explain the interpSpeed part a bit clearer? No matter what value I enter there, the ship turns instantly. I already have a ‘TurnSpeed’-float for that specific ship (as you can see in my screen). Could I reuse that? Where/how should I plug it in?

Mod: I forgot to plug in the InterpSpeed variable in the RInterp To-node. No wonder nothing changed. :wink: Thanks for the help!