Analog Joystick Rotation

I seem to be having issues with analog joystick rotation.
It weirdly snaps to diagonal rotations and I cannot for the life of me fix this.

        // Get input
        inputVector.X = Input.GetAxisRaw("MoveX");
        inputVector.Y = Input.GetAxisRaw("MoveY");

        // Calculate input direction
        inputDir = new Vector3(inputVector.X, 0, inputVector.Y)Normalized;
        Dir = Camera.Transform.TransformDirection(inputDir);


            Quaternion targetOrientation = Quaternion.LookRotation(Dir, Camera.Transform.Up);
            ForwardArrow.Orientation = Quaternion.Slerp(ForwardArrow.Orientation, targetOrientation, rotationSpeed * Time.DeltaTime);

(few of the names have been changed for more clarity)

I have tried every code I could find. When reading the debug log its as if when pressing towards diagonals the input jumps to beyond its maximum. Any help appreciated.

Perhaps I’m missing something here, but it appears you get a Vector3, normalise it (giving it a length of 1), then compare its LengthSquared (which will always be 1, so not sure why you do that) to 0

1 is always > 0, so basically you do some stuff then always execute your two quaternion operations.

Oh AI you are right. Let me edit these bits out. This was quickly slapped together as the code had been bastardized over and over.
I will change the code box to the basic version of the code I am having issues with.

EDIT : I have realized its an issue with how the analog stick axis registers. If you lightly touch the stick and move it around you get analog control however if you slightly push it forwards it becomes Digital. Its like the Analog acts both digitally and Analog at the same time.
I don’t want this. i want a nice smooth 360 turn.

Ok I am an idiot/n00b.
When assigning the inputs I have been assigning the Positive and Negative when actually all you have to do is assign “left stick X” and “left stick Y” and it does the rest. Phew. Now I can get on with this game. I shall close the topic

1 Like