Re: Issue with converting a facing to a Vector3.Z value to look at [message #464480 is a reply to message #464420] |
Fri, 16 March 2012 06:58 |
|
Jerad2142
Messages: 3812 Registered: July 2006 Location: USA
Karma:
|
General (3 Stars) |
|
|
It's off because as he turns different directions you're doing the trig function sin and multiplying it by 20, then adding it to the height of the player you're following.
Facing only gets the Z facing of an object, not the Y and X tilt.
The best you'll be able to do is fake it (unless 4.0 gives you data exactly regarding what angle the player is looking up and down at). The easiest way to fake it that comes to mind is that you could get the difference in height between the right hand bone and the right shoulder bone of the soldier you're following. Then you just have to do some math fun:
pos2.Z += (1/HeightDifference)*20.0f;
It won't be perfect, nor will it be as good as if you actually figured out the angle between the shoulder and the hand with atan2 or something, but I'd recommend you test it with something basic first, that way if it doesn't work at all (IE: although the players arms angle to aim where they are looking on the clients computer, I'm not sure if the fds does anything more than play 3 different animations depending if your looking up, down, or straight forward, this would mean that your camera would only have 3 different heights from the player).
However, I think its worth a shot as it'd be pretty easily to implement, unless someone else has an idea.
Visit Jerad's deer sweat shop
|
|
|