I need help making the character look at stuff with SkeletonModifier3D

Godot Version

4.3

Question

Hi! I’m at my wit’s end with this. Recently I updated Godot to 4.3 because of the new SkeletonModifier3D to animate my character while moving its head.

I followed this post and used part of the code to make it work, but used a method similar to the look_at() function that godot already has instead of the _y_look_at(from: Transform3D, target: Vector3) that appears on the post.

func look_at_copy(p_eye: Transform3D, p_target: Vector3):
	var v_x
	var v_y
	var v_z
	v_z =  p_target - p_eye.origin
	v_z.normalized()
	v_y = Vector3.UP
	v_x = v_y.cross(v_z)
	v_y = v_z.cross(v_x)
	v_x.normalized()
	v_y.normalized()
	p_eye.basis = Basis(v_x, v_y, v_z)
	return p_eye

This works on the player scene but not on others. I think it’s because of the position of the player in the scene.
I don’t know how to take the global/actual position of the player/skeleton and use it :melting_face:

To illustrate what is happening:

Can you check to make sure your Player node (the cat) hasn’t rotated yet

Hi! Do you mean if it hasn’t rotated in it’s original scene? Then no, and in other scenes it must rotate as the player moves on the scene.

when you only import the cat to the scene does this happen?

So, after your comment I thought about testing it differently. I found the problem after A LOT of testing and it was awful because it started working on some scenes and on others it had some erratic behaviour, so I started importing small things little by little in to a new scene. It appears that the root node of the scene on some scenes was displaced, making it look at an object as if it was far away. Other objects simply have the root of their original scene displaced so the player looks at them weird…
TLDR: the root node of the scene was displaced and caused a lot of weird behaviours.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.