+1 vote

Hello is there a way to make the camera rotate smoother, i am making a rotation for my camera by scratch to use with buttons since alot of tutorials only show Mouse most of the time and i got this from the Godot Docs:

However the rotation is mega violently fast and i cant figure out how to smooth it out or "Slow the rotation down"

this is the code im using:

rotate_object_local(Vector3(0, 1, 0), PI)
    transform = transform.orthonormalized()

How can i fix this?

Godot version 3.3
in Engine by (39 points)

2 Answers

0 votes

You need to lerp (linear interpolation) the transform, or use a tween if you want more control on the type of smoothing curve.

With lerp you could do something like this:

func _process(delta):
    transform = lerp(transform, new_transform, 0.2) 

You can set the new_transform somewhere in your code when a player is pressing a key or something. 0.2 means the value will be reduced by 20% each time the function is called. Adjust it to your liking

Tween: https://docs.godotengine.org/fr/stable/classes/class_tween.html
Lerp: https://docs.godotengine.org/fr/stable/classes/class_@gdscript.html?highlight=lerp#class-gdscript-method-lerp

by (617 points)
0 votes

If you call this in _process(delta),make sure you multiply the PI by delta.

by (1,055 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 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 webmaster@godotengine.org with your username.