Topic was automatically imported from the old Question2Answer platform.
Asked By
mstfacmly
I’m working on an on-rails-shooter using the current 3.1 beta, where one of the manoeuvres has the player ship rotate on itself (like a barrel-roll). I can get it to rotate around itself, but it doesn’t quite work as planned. This is what it currently looks like in action
Notably: the ship does a full 360* reverse roll back to the 0 position, instead of completing a roll from 270*, or going back to 0 after breaching the initial rotation . Is there a way to force a 360* rotation to be seen as going back to 0 upon going a bit above?
I tried doing something along the lines of this question, but it doesn’t work with what I have.
Here’s the current code that I’m using for the effect:
var angles = Vector3() if tilt_lr: > tilt += tilt_lr * TILT_SPEED >> if roll: >>> tilt += tilt_lr * ROLL_SPEED if abs(rotation_degrees.z) >= ROLL_SPEED > tilt += tilt_lr * 0.0 var flight_dir = Vector3(pitch,yaw,tilt) angles = angles.linear_interpolate( flight_dir, ROTATE_SPEED * dt ) set_rotation_degrees(angles)
Hey, thanks for the answer. It doesn’t seem to help with regards to getting the roll working correctly. I posted a link to its current behaviour in the original post, in case that helps better see what I’m looking to do.
For further clarification: when I look at the output of rotation_degrees.z, it would go up to 180*, and roll back to 0*. I’m thinking that if I can have the degree count be “reset” as it’s reaching a certain point, the rotation would complete correctly instead.