0 votes

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!

in Engine by (227 points)

1 Answer

0 votes
Best answer

look_at_from_position() and look_at() are void functions. See here: http://docs.godotengine.org/en/3.0/classes/class_spatial.html#class-spatial-look-at
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:
http://docs.godotengine.org/en/3.0/classes/class_transform.html#class-transform-looking-at
Example:

self.transform = self.transform.looking_at(Vector3(10, 0, 5), Vector3(0,1,0))
by (210 points)
selected by
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.