Godot Version
4.3
Question
I am new to Godot, like really new so excuse me.
I am trying to set up a third person character controller. The Problem I’m facing right now is that the animation tree (more precisely the blend2D) seems to be overwriting the rotation of my character, which i update based on the WASD inputs of the player. It does work with the AnimationTree inactive, but not if it is active. I followed some tutorials and none ran into this problem.
here is my Character script
extends CharacterBody3D
const SPEED = 15.0
const JUMP_VELOCITY = 4.5
const LERP_VAL = 0.15
@onready var armature = $Armature
@onready var spring_arm_pivot = $CameraController
@onready var anim_tree = $AnimationTree
func _unhandled_input(event: InputEvent) → void:
if Input.is_action_just_pressed(“quit”):
get_tree().quit()
func _physics_process(delta: float) → void:
armature.rotation.y = lerp_angle(armature.rotation.y, atan2(velocity.x, velocity.z), LERP_VAL)
anim_tree.set_active(true)
anim_tree.set(“parameters/Movement/blend_position”, Vector2(-velocity.x, -velocity.z))
# Add the gravity.
if not is_on_floor():
velocity += get_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("left", "right", "forwards", "backwards")
var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
direction = direction.rotated(Vector3.UP, spring_arm_pivot.rotation.y)
if direction:
velocity.x = lerp(velocity.x, direction.x * SPEED, LERP_VAL)
velocity.z = lerp(velocity.z, direction.z * SPEED, LERP_VAL)
else:
velocity.x = lerp(velocity.x, 0.0, LERP_VAL)
velocity.z = lerp(velocity.z, 0.0, LERP_VAL)
move_and_slide()
Is this just a problem with importing animations that themselves modify rotation?
(unfortunately i cannot upload a vid of what i mean but i think you get the rough idea)