look_at() returns Null

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By websterek

HI, how should I use look_at() funcion? Right now with this sample code below it’s always returning Null to Output

extends Spatial
    
func _ready():
	# Called when the node is added to the scene for the first time.
	# Initialization here
	pass

func _process(delta):
		
	if Input.is_action_just_pressed("ui_accept"):
		print(look_at_from_position(Vector3(0, 0, 0), Vector3(10, 0, 5), Vector3(0, 1, 0)))

Greetings!

1 Like
:bust_in_silhouette: Reply From: metin

look_at_from_position() and look_at() are void functions. See here: Spatial — Godot Engine (3.0) documentation in English
It returns nothing because this function applies the transformation and you don’t need to assign it anywhere.
If you really need the transformation matrix then use looking_at() on the transform of your spatial. See here:
Transform — Godot Engine (3.0) documentation in English
Example:

self.transform = self.transform.looking_at(Vector3(10, 0, 5), Vector3(0,1,0))
1 Like