Hey, I'm new to Godot and programming in general, but I'm steadily learning. I've made a pretty simple third person character controller but I'm having an issue with getting lerp to fuction in my script. This would be to rotate along the Y axis and in the direction that the player would be moving. Thanks for the advice.
`func _ready():
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
func _input(event):
if event is InputEventMouseMotion:
rotate_y(deg_to_rad(-event.relative.x * sens_horizontal))
visuals.rotate_y(deg_to_rad(event.relative.x * sens_horizontal))
camera_mount.rotate_x(deg_to_rad(event.relative.y * sens_vertical))
camera_mount.rotation.x = clamp(camera_mount.rotation.x, deg_to_rad(-50), deg_to_rad(65))
func _physics_process(delta):
#Declare lock fuction. Means the player cant move but can look around.
if !animation_player.is_playing():
is_locked = false
#Handle Kick.
if Input.is_action_just_pressed("kick"):
if animation_player.current_animation != "animation-library/Kick":
animation_player.play("animation-library/Kick")
is_locked = true
#Handle Run.
if Input.is_action_pressed("move_run"):
speed = running_speed
running = true
else:
speed = walking_speed
running = false
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta
# Handle Jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = jump_velocity
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir = Input.get_vector("move_right", "move_left", "move_backward", "move_forward")
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
if !is_locked:
if running:
if animation_player.current_animation != "running-anim/Running":
animation_player.play("running-anim/Running")
else:
if animation_player.current_animation != "Walk":
animation_player.play("Walk")
visuals.look_at(position - direction)
velocity.x = direction.x * speed
velocity.z = direction.z * speed
else:
if !is_locked:
if animation_player.current_animation != "Idle":
animation_player.play("Idle")
velocity.x = move_toward(velocity.x, 0, speed)
velocity.z = move_toward(velocity.z, 0, speed)
if !is_locked:
move_and_slide()`