0
\$\begingroup\$

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.

Before: Before

After: After

Video Link: Error

This is what I want to happen: Picture

Picture of error: Error

Extra info: GlobalBasis

\$\endgroup\$
3
  • \$\begingroup\$ "I printed the basis out, and it was not zero" can you include the printed basid in the body of your question? A matrix determinant can equal zero even if each row/column is non-zero, if two or more of its rows/columns are linearly dependent (i.e. if we can express one row or column as a weighted sum of the others). \$\endgroup\$
    – DMGregory
    Commented Mar 13 at 12:56
  • \$\begingroup\$ I have included a screenshot of the basis down below and what errors i got,is there anything else i need to do? \$\endgroup\$
    – NEWBIE
    Commented Mar 13 at 13:21
  • 1
    \$\begingroup\$ The "After Change" basis has a determinant of -1 in my figuring. Are you sure that's the matrix that's throwing the det == 0 error? \$\endgroup\$
    – DMGregory
    Commented Mar 13 at 13:52

0

You must log in to answer this question.

Browse other questions tagged .