For my project I am turning my CharacterBody3D
90 degrees on the x-axis towards a wall.
To achieve this I set basis.Z
to the basis.Y
, and then I set basis.Y
to the Normal
.
The X
should stay the same, so I did not do anything with it.
When I tried this I kept getting invert:condition "det==0" is true
errors. I printed the basis out, and it was not zero, so I checked the scale and the transformation, which were also non-zero.
I looked up online and can't figure out what I'm missing. Code for current attempt:
GD.Print("This is the scale Before Change: " + Scale);
Vector3 DistanceBetweenColliderpoints = Position - ColliderPosition;
GlobalPosition = Position + (DistanceBetweenColliderpoints / 4);
Basis basis = GlobalBasis;
basis.Z = basis.Y;
basis.Y = Normal;
UpDirection = Normal;
GlobalBasis = basis;
GD.Print("This is the scale After Change: " + Scale);
GD.Print("Normal: " + Normal);
Code from past attempt:
Vector3 DistanceBetweenColliderpoints = Position - ColliderPosition;
GlobalPosition = Position + (DistanceBetweenColliderpoints / 4);
Basis basis = GlobalBasis;
basis.Y = Normal;
basis.Z = Normal.Cross(basis.X);
basis.X=basis.Z.Cross(Normal);
GlobalBasis=basis;
I also did this with transform, and it gave me the same error.
Video Link: Error