The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+1 vote

I am currently trying to use slerp but godot complains about it not being a normalized vector, the error is exactly this (setaxisangle: The axis Vector3 must be normalized)

I tried adding normalize to everything it complains, nothing changes.

code down below:

extends Spatial

var current_rotation = Vector3()
var target_rotation = Vector3()

export (float) var recoil_X
export (float) var recoil_Y
export (float) var recoil_Z

export (float) var snappiness
export (float) var return_speed

func _physics_process(delta):
    target_rotation = lerp(target_rotation,Vector3.ZERO,return_speed * delta)
    current_rotation = current_rotation.slerp(target_rotation,snappiness * delta)
    if Input.is_action_just_pressed("B"):
    set_rotation_degrees(target_rotation)  # I think this sets the rotation

func recoil_fire():
    target_rotation += Vector3(recoil_X,rand_range(-recoil_Y,recoil_Y),rand_range(-recoil_Z,recoil_Z))
Godot version 3.4
in Engine by (161 points)

2 Answers

0 votes

From Vector3.slerp()

Note: Both vectors must be normalized.

Normalize vectors with Vector3.normalized()

by (887 points)

I followed a unity tutorial and they used slerp as well and they didn't need to normalise the vectors, actually normalising the vectors makes what I want it to do completely wrong, but thanks for answering anyways

0 votes

I think slerp needs two vectors to be able to run. At least, it's what the documentation says, or I'm interpreting wrong... And both vectors must be normalized().

I didn't used slerp yet, only lerp. So I can't tell you what it exactly does or how you can write...

by (20 points)
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.