look_at_from_position() function not working

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

I have created a spacial node called Troll, which has two children: Troll and Sight. Both of them are areas. This is my code for the spacial Troll:

extends Spatial

var velocity = Vector3(0, 0, 0)
var saw = false
var player = null
const SPEED = 2

func _process(delta):
	if saw == true:
		look_at_from_position(player.position, player, Vector3(0, 1, 0))
		velocity.y += SPEED

func _on_Troll_body_entered(body):
	player = body
	saw = true


func _on_Troll_body_exited(body):
	player = null
	saw = false

This is the error:
Invalid type in function ‘look_at_from_position; in base "Spatial (MainTroll.gd)’. Cannot convert argument 2 from Objects to Vector3.

“MainTroll.gd” is the script (shown above)

Do you know what’s wrong? Sorry, I’m new to this function.

:bust_in_silhouette: Reply From: Noddy

player is an object not a Vector3. You can only use Vector3’s as arguments for this function. Also for the player.position part, you actually want to use player.translation as player.postition is for Node2D not Spatial. Here’s some [documentation] 1 that should help.

Then what should the Vector3 Target be?

Squabix | 2019-06-21 16:08