Slerp'ing between local transforms throws "set_axis_angle: The axis Vector3 must be normalized." err

ArandualArandual Posts: 4Member
edited June 30 in Programming

Previously titled: "Wrong error: set_axis_angle: The axis Vector3 must be normalized."
I figured out that var tpCheckNow = tpCheck.get_transform().origin caused this error to be thrown, and using var tpCheck.get_global_transform().origin fixes it. But it causes undesired results, how do I use slerp with local transforms?

So I have this little piece of code (see below) which works as expected and doesn't seem to have any side effects.

var tpCheckNow = tpCheck.get_transform().origin
var tpCheckGoal = tpOrient

var tpSlide = tpCheckNow.slerp(tpCheckGoal, 0.12)

Basically I have a teleportation marker (which shows shows where the player will teleport to) and it changes location based on where the player is moving towards. That all works fine, but I keep getting the "set_axis_angle: The axis Vector3 must be normalized. <C++ Error> Condition "!p_axis.is_normalized()" is true. <C++ Source> core/math/basis.cpp:803 @ set_axis_angle()" Error.

I have tried normalising every vector involved (tpCheckNow, tpCheckGoal & tpSlide) I have even tried it in different places. But for some reason it keeps throwing this error and it completely floods the debug window.
The trace also shows it specifically comes from the third line of code from this snippet. (where tpSlide is declared)


Tags :

Answers

  • TwistedTwiglegTwistedTwigleg Posts: 2,641Admin
    edited June 30

    Welcome to the forums @Arandual!
    With tpCheckGoal, maybe call orthonormalized (documentation) before calling slerp and see if that fixes it?

  • ArandualArandual Posts: 4Member

    @TwistedTwigleg Thank you for welcoming me and the quick reply!
    I am not sure how I would call orthonormalized on a Vector3 (since it is related to basis) though, perhaps I forgot to mention but all variables involved are Vector3 types.

    I am not manipulating rotation in anyway, only the location.
    Still thanks for the reply, have a nice day!

  • TwistedTwiglegTwistedTwigleg Posts: 2,641Admin

    Ah, okay. I was thinking it was a Basis because of the error. Have you tried using linear_interpolate? Also, another thing that could be causing the issue is that one or more of the Vectors are zero, which would cause the function to fail even if the vectors are normalized.

  • ArandualArandual Posts: 4Member

    So I reworked my scene a little and cleaned it up.
    I found out a few interesting things...

    linear_interpolate works, and doesn't give errors, but it doesn't give quite the same effect.
    I basically have a marker (tpCheck) at x distance away from the player, but it is part of the player scene.
    This marker then reads the input given by the user and then moves towards that location... when using slerp it circles around the player and when using linear_interpolate it can actually get closer to the player.

    But when I tried to use the global transform of the marker slerp didn't give that error anymore, but it did cause it to move off into infinity on whatever axis the player is facing.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file