+1 vote

I am trying to add bullet holes to my FPS whenever you shoot. I am changing the values of the bullet hole instance's GlobalTransform in a variable and then setting it to the variable. This worked fine for the origin, but it is not working for the basis. I need to change the basis to have it face the correct direction.

Here is my code:

Vector3 y = normal;
Vector3 x = y.Cross(Vector3.Up);
Vector3 z = x.Cross(y);

globalTransform.basis = new Basis(x, y, z);
GD.Print("Variable basis: " + globalTransform.basis);

hitEffectInstance.GlobalTransform = globalTransform;
GD.Print("Instance basis: " + hitEffectInstance.GlobalTransform.basis);

And here is an example of the printed output when I shoot a slanted surface:

Variable basis: ((-0.538021, 0, 0), (0, 0.8429316, 0.2894666), (0, 0.538021, -0.4535148))
Instance basis: ((1, 0, 0), (0, 1, 0), (0, 0, 1))
Godot version 3.3.2.stable.mono
in Engine by (13 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.