Last active
June 30, 2020 21:49
-
-
Save zwazel/9771e28a3bbb44ab3ecdaa69695bde40 to your computer and use it in GitHub Desktop.
Godot Useful Functions - Slowly turn object towards another object in 3D space
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Slowly turn object towards another object in 3D space | |
func turn_face(target, rotationSpeed, delta): | |
var global_pos = global_transform.origin | |
var wtransform = global_transform.looking_at(Vector3(target.x,global_pos.y,target.z),Vector3(0,1,0)) | |
var wrotation = Quat(global_transform.basis).slerp(Quat(wtransform.basis), rotationSpeed*delta) | |
global_transform = Transform(Basis(wrotation), global_transform.origin) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Shoutout to M15F17 for giving me this wonderful code snippet, I modified it a little bit so that it fits my game.