Topic was automatically imported from the old Question2Answer platform.
Asked By
Retroarchy
I’m trying to rotate the player_head spatial (which has a camera as a child) up by 15 degrees when I press the look up button and back down when I release it. I have that system working but it just snaps to 15 degrees and back, instead of interpolating between the values. I’ve tried using the lerp functions with it and nothing is working out so far. I have no idea how I could do it with Tweens since I’m really unfamiliar with Tween Node.
Here’s the code for simply looking up and back down 15 degrees.
func _physics_process(delta):
if Input.is_action_just_pressed("player_look_up"):
rotation_degrees.x = 15
if Input.is_action_just_released("player_look_up"):
rotation_degrees.x = 0
tween node
'ts like magic
also I hate using it lol
HalfAsleepSam | 2022-11-19 05:33
at least your hatred still compels you to
never have and probably never will since the lerp() and move_toward funcs exsits
You can use an AnimationPlayer node and then where you change the rotation value in your code just play that animation.
You can us a tween node, and execute that where you change the rotation value in your code.
Those will get you the best looking result but you could also change the value incrementally using a loop.
var lookUpMaxRotation = 15
lookUpSpeed = 1
if Input.is_action_just_pressed("player_look_up"):
while rotation_degrees.x < lookUpMaxRotation:
rotation_degrees.x += lookUpSpeed
if Input.is_action_just_released("player_look_up"):
while rotation_degrees.x > 0
rotation_degrees.x -= lookUpSpeed
I didn’t test that chunk of code but it should work, and you could adjust the speed by changing the lookUpSpeed.
Thank you for this, but this just seems to snap the camera up again instead of incrementally doing it. I’ve adjusted the speed to various values and it still just snaps up and down.