lookat problem

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

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 on other sites
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 on other sites
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 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:

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 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.

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 10
• 14
• 30
• 13
• 11
• Forum Statistics

• Total Topics
631790
• Total Posts
3002367
×