Can anyone with significant experience in Godot explain what I'm doing wrong with my transforms?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jagbe

I’ve been at this for nearly three days straight now (16 hours+ daily). Godot transforms are slapping me across the face.

First I wanted to use Mixamo animations in Godot. This was torturous, and through pure trial and error I finally came up with a workflow that succeeded.

Then I got to work on a very simple third-person character controller.

enter code here extends KinematicBody


var curHp : int = 10
var maxHp : int = 10
var damage : int = 1

var gold : int = 0
var attackRate : float = 0.3
var lastAttackTime : int = 0

export var moveSpeed : float = 5.0
export var jumpForce : float = 10.0
export var gravity : float = 15.0
export var upForce: float = 3.0
export var vel : Vector3 = Vector3()

onready var camera = get_node("CameraOrbit")


# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.

func _physics_process(delta):
vel.x = 0
vel.z = 0

var input = Vector3()
if Input.is_action_pressed("move_forward"):
	input.z -= 1
if Input.is_action_pressed("move_backward"):
	input.z += 1
if Input.is_action_pressed("move_left"):
	input.x -= 1
if Input.is_action_pressed("move_right"):
	input.x += 1
	
input = input.normalized()

var dir = (transform.basis.z * input.z + transform.basis.x * input.x)
print(dir)

vel.x = dir.x * moveSpeed
vel.z = dir.z * moveSpeed
# gravity
vel.y -= gravity * delta
if Input.is_action_pressed("move_jump") and is_on_floor():
	vel.y = jumpForce

#move along the current velocity
vel = move_and_slide(vel, Vector3.UP)
# transform = transform.orthonormalized()
func divideButAvoidZero(divisor, dividend):
if divisor == 0:
	return 0
else:
	return dividend / divisor

It was working well.

I then created four 1 frame animations that rotated (transform) the player model.
I put all four animations into two 1 dimensional blend spaces and then used the add node to combine them with the idle animation.

This worked fine, but after flying around for a bit in the game the animations invert (moving right plays left-leaning animation instead).

Very shortly afterwards the camera movement inverts as well (moving the mouse up makes the camera look down).

I believe that I am unknowingly messing up the transform basis of the character controller, but I don’t know how, why or when. I’ve never been this stuck on anything before.

Does this sound familiar to anyone?

Here is the link to the repository