Instead of coding many lines of code each time,
a high level simplified function to rotate an object to face another object position.
TurnTo ( Vector3 position, Vector 3 axisTurn, bool direct, float speed, bool lerping)
Vector3 position: object to turn to
Vector 3 axisTurn : axis rotation to use
bool direct : turn directly , don' t use speed
float speed : rotation speed for turn
bool lerping : should use lerping when it uses speed
It's already simple enough. You can use the set_look_at(...) and interpolate_with(...) functions of Transform to achieve such behavior easily.
What you propose is too specific to end up into the core.
Or basically follow the comments there #21383.
As your link, this new function is to avoid all those code lines.
About look_at, you can' t restrict two axis.
Fore example Vector(0,1,0) ; will allow the object to rotate on Y and X axes.
While it should be possible to allow only Y rotations for example.
Godot needs some high levels functions for very common things, like those Unity has.
About look_at, you can' t restrict two axis.
Yes you can, you simply have to change the look target. By basically putting your target as the same coordinates on the axis you want to restrict.
Godot needs some high levels functions for very common things, like those Unity has.
No, that's not Godot philosophy.
It might be a common thing, but there are a lot of ways to handle such movement. That's why such proposal is mostly pointless as too specific. The look_at and interpolate_with functions ease the work enough.
Same coordinates as target is some good idea, unfortunately there was no examples on documentation to show different ways to use it :(
I don't understand, how can you rotate with lerp some object to another using look_at ?
When you use look_t the object is directly rotated you can't no more use lerp.
Why not combininig the two in some look_at_lerp() ?
Here we are, three lines of code :
func _process(delta):
var target = $"../target".global_transform.origin
var target_transform = Transform().looking_at(target, Vector3(0,1,0))
global_transform = global_transform.interpolate_with(target_transform, 1 * delta)

Why not combininig the two in some look_at_lerp() ?
Because there is not more reason for that than implementing color_lerp() or anything_lerp(). We have generic functions for that, adding specific function for each case is just bloat into the API.
That's a good explanation.
Could those be in the docs ?
Yes you can, you simply have to change the look target. By basically putting your target as the same coordinates on the axis you want to restrict.
func _process(delta):
var target = $"../target".global_transform.origin
var target_transform = Transform().looking_at(target, Vector3(0,1,0))
global_transform = global_transform.interpolate_with(target_transform, 1 * delta)
I agree that this should go in the docs as it's often requested, and though it's relatively simple as shown by @groud, it's not always trivial to come up with from scratch.
@godotengine/documentation any advice on where to put it?
Yes, it's one of the most used and requested features for 3D games.
It should be in the docs.
About look_at, you can' t restrict two axis.
Yes you can, you simply have to change the look target. By basically putting your target as the same coordinates on the axis you want to restrict.
Thanks, it worked.
var lookPos = player.global_transform.origin
lookPos.y = global_transform.origin.y
look_at(lookPos,Vector3(0,1,0))
Look At on Y axis is the most used , it could be added to the manual.
@akien-mga I have 2 places in docs to propose:
The example would feet very well in "3D transform"
Or in a sub section named "How to"
https://docs.godotengine.org/en/3.1/tutorials/3d/using_transforms.html
Most helpful comment
Here we are, three lines of code :
Because there is not more reason for that than implementing color_lerp() or anything_lerp(). We have generic functions for that, adding specific function for each case is just bloat into the API.