Ok, I have been at this for a while, most didn't work, some work but then continu on rotating and I don't know a what to adress to stop that roation at the angle I want.
But since the "button" that invokes this camera angle change is a joystick which can be held or let go at any moment and the angle needs go from one to the other smoothly... and back when let go.
I think it's best to use a tween and interpolate. And apparantly you have interpolatemethod and interpolateproperty. Most of the parameters I understand, but the 2nd one is the problem, what you need to fill in as property or method. Because online I see it different with everybody and none of them work. It's annoying to constantly hitting these sort of problems without finding/getting a straigth answer. It all goes from very easy to extreme hard with no explanation at all. You find posts with problems, but most of the time only mentioned they managed to get it working, but not sharing what that exactly.
So for now, I need help getting my tween right. What do I need to do to rotate around my Y-axis of the camera. I know it can work, I've done it with objectlocalrotate and having a lerp in it,
rotate_object_local(Vector3.UP, lerp(0, 2, look_around * t)) but that just keeps on spinning and I don't which value to stop it.
So this is the code I'm trying to work with. This function gets called in the physicsprocess():
var tween = Tween
look_around = Input.get_action_strength("turn_left") - Input.get_action_strength("turn_right")
if (abs(look_around) == 1.0):
print("tweening") #just to test if it's even getting here.
tween.interpolate_method(self, "rotate_object_local", 0, 20 * look_around, 3, Tween.TRANS_LINEAR, Tween.EASE_OUT)
I don't want a TweenNode in my Scene-Tree, want to do this by code.
So how get I get things turning? For the 2nd parameter, I've set others things aswell, like
set_rotation and such.
I've set 0 and 20 for the next parameters, because I want to start from the rotation I'm currently at, to 20 degrees either left or right ( look_around is either going to be -1 or 1 so it know which way to turn).
I know this probably could be wrong, because I've done a
print("looking around: %s" % str(rad2deg(get_camera_transform().basis.get_euler().y))) and it said something of -179,998887.
The 3 is hopefully the seconds?
And while I'm at it... didn't get a timer to work either. Apparently that is what I need, because I only want the tween to happen when the joystick is held at 1 or -1 for more than two seconds.
Don't worry about the
if (abs(look_around) == 1.0): . It works and I'll be changing it later as somebody gave me the advice of trying to avoid using
== and it's better to do
And I assume, if the true statement works, the false statement will automatically work by changing parameter 3 and 4, right?
I understand what Tweening is, I've done it many times in Flash/ActionScript (yeah I know, it isn't used anymore).
So I just want help to get this working. What does it take to make this tween work?