Getting unexpected error about vector3 - need to be normalized

Godot Version

4.5 stable

Question

Hi I have this line in code

func _input(event:InputEvent) -> void:
	if _rotate_show_tem:
		var _mouse_input: = event is InputEventMouseMotion
		if _mouse_input:
			var _rotate_input :Vector3 = Vector3(event.relative.y, event.relative.x, 0.0)
			mesh_owner.rotate(_rotate_input.normalized(), mouse_sensitivity)

all works fine I rotate item in accordance to mouse movement but i get error every time i do:

E 0:00:03:725 interactive_control.gd:38 @ _input(): The axis Vector3 (0.0, 0.0, 0.0) must be normalized.
<C++ Error> Condition “!p_axis.is_normalized()” is true.
<C++ Source> core/math/basis.cpp:843 @ set_axis_angle()
interactive_control.gd:38 @ _input()

confusing it goes away when on my Vector3 i put value 1.0 for z axix
var _rotate_input :Vector3 = Vector3(event.relative.y, event.relative.x, 1.0)
but then rotation seems clunky

any suggestion how to get rid off this error msg?

I’m assuming event.relative is occasionally (0.0, 0.0), resulting in that Vector3(0.0, 0.0, 0.0) that can’t be normalized.

If that’s the case an additional check if not event.relative.is_zero_approx(): should fix the issue.

1 Like

Awesome, it solved this issue, thank you! :slight_smile:

1 Like