Godot Version
godot-4, gdscript, 3d, game
Question
`Hey, starting out with a 3d game and I just wanted to know how I can rotate my character towards the direction I’m moving, currently I’m using lerp, but by holding in the direction the character never stops, wanted to know if there’s a better way to tackle this, I have a video where I repeatedly tap the a and d buttons and the cart doesn’t stop rotating. Any Idea on how to help?? here’s the code:
extends Sprite3D
var min_ang = deg_to_rad(0.0)
var max_angle = deg_to_rad(5.0)
var elapsed = 0.0
func _physics_process(delta):
if Input.is_action_pressed(“move_left”):
rotation.y = lerpf(min_ang, max_angle, elapsed)
elif Input.is_action_pressed("move_right"):
rotation.y = -0.4
else:
rotation.y = 0
elapsed = 0.0
elapsed += delta * 5