Sign in to follow this  

lookat problem

This topic is 4276 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi there we have a character in game, to make it more real, we're going to control its head directly so it will be able to look at anything we want it to, its skined mesh and the bone we pick to be controled is 'head bone', the bone itself is on hierarchy. its easy to make it look at whatever we want it to (for example the camera), but the problem is its often rotated too much so the final character's head is terribly twisted while staring at me (or the camera). so i want to know how to solve this problem? is IK needed? for now my computation for the lookat rotation is : forward = target_pos - head_pos; side = cross(forward, vector3(0, 1, 0)); up = cross(side, forward); compose_rotation_matrix(side, forward, up); thanks.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
umh... maybe this is too obvious
but seeing as how humans can't turn their necks more than about 90degrees to either side...
maybe you need to limit how far your character's neck is allowed to turn?
I'm guessing by 'terribly twisted' you mean the character is moving it head too far and looking... physically uncomforatble...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
if the character's neck is twisting too much
don't program it to twist so much

...yup... that should do the trick


ok, seriously though
check and see if what you want the characer to look at is within 'not too twisted' degrees. if it is, then let him look at it.
if it is going to be too far, then turn it off so he stops trying to look at it.

Share this post


Link to post
Share on other sites
What I have done in the past is create an angle constraint. When you go to look at a point:

- Vector v = point - headposition
- Vector f = the direction that the character is facing
Both normalized.

if angle between v and f is greater than constraint:
Look forward instead.

That way, if he can't see the point, he will not twist his neck trying to look at it, and instead will look forward.

Share this post


Link to post
Share on other sites
thanks for the replies -- i have found the reason why it twisted that way : i calculated the rotation in wrong space. but i noticed another flaw : sometimes the head turns in wrong direction though its final lookat direction is correct. for now i have no idea how to always rotate it correctly, im using quaternion slerp, anyway i'll try to find cure for this on my own first.
p.s. i still think its not enough by rotating its head only, it looks fake sometimes, maybe i should try IK to make it more realistic.


Share this post


Link to post
Share on other sites

This topic is 4276 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this