This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
0
Help needed in fixing my eye tracking code
Post Body
I need some feedback on my eye tracking code. Something is wrong either with it or with the eye bones, and I can't figure out what exactly. Firstly, I can only set the direction from the "head" bone and re-use it later for the eye bone, but it is not very precise, I feel. When I uncomment the code in the second pic, the eye goes in a random extreme direction, Secondly, the eyes point lower (3rd pic) than they should (should be on the carrot). Do you spot any mistakes?
func look_at_target(delta):
if target:
var targ = target.global_transform.origin
var target_pos = $skeleton.to_local(targ)
var bone = $skeleton.find_bone("DEF-neck.001")
var pose : Transform3D = $skeleton.get_bone_global_rest(bone)
var direction = (pose.origin - target_pos)
var look_at_point = pose.origin direction.normalized()
var pose_new = pose.looking_at(target_pos, Vector3(0,1,0))
var angle = (-pose.basis.z).angle_to(-pose_new.basis.z)
angle = clamp(angle, deg_to_rad(-80), deg_to_rad(80))
var axis = ((-pose.basis.z).cross(-pose_new.basis.z)).normalized()
pose = pose.rotated(axis, angle)
pose = pose.orthonormalized()
$skeleton.set_bone_pose_rotation(bone, pose.basis)
bone = $skeleton.find_bone("DEF-eye.L")
pose = $skeleton.get_bone_global_rest(bone)
#direction = (pose.origin - target_pos)
#look_at_point = pose.origin direction.normalized()
pose_new = pose.looking_at(target_pos, -pose.basis.y)
angle = (pose.basis.y).angle_to(pose_new.basis.y)
angle = clamp(angle, deg_to_rad(-80), deg_to_rad(80))
axis = ((pose.basis.y).cross(pose_new.basis.y)).normalized()
pose = pose.rotated(axis, angle)
pose = pose.orthonormalized()
$skeleton.set_bone_pose_rotation(bone, pose.basis)
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 4 months ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/godot/comme...