Not at all. The script I wrote was the root of the plane and wasn't faking anything. If you use a RigidBody
, you must use its functions instead to add forces to it. That means you can't just copy/paste my code, but perhaps find some calculations that might be useful to you. At least make sure to understand how such a system works, then find how to do each step.
For faking it, it might look a bit worse but it's simpler. You'd basically move your plane, not rotate it. Rotation would only be applied on visuals every frame, and you could have a roll variable used to set the Z rotation once other rotations got applied. When turning, you increase roll
, and when you stop turning, you decrease it. I haven't done this kind of faking before though.
first set rotation around global Y, then rotate around the local Z axis.
# Set the two lookat angles (you could use look_at as well?)
set_rotation(Vector3(rotation_x, rotation_y, 0))
# Apply roll
rotate_object_local(Vector3(0, 0, -1), roll)
Then for roll, something like this in _fixed_process
:
# Pseudocode!
var max_roll = PI / 4.0
if moving left:
# Increase roll to the left
roll = clamp(roll + delta * PI, -max_roll, max_roll)
elif moving right:
# Increase roll to the right
roll = clamp(roll - delta * PI, -max_roll, max_roll)
else:
# Dampen roll
roll = lerp(roll, 0.0, delta)
However this is just an idea for faking, I haven't covered looking up and down, you'll have to tinker with a solution yourself.