Animating an AIPlayer's head
by Rubes · in Torque Game Engine · 05/19/2008 (11:06 am) · 7 replies
Just hoping for a little clarification on how this might be done.
I'd like to have the NPC's in my game (AIPlayers) turn their head to face the player when they speak. Since the player can approach the NPCs from a number of different angles, it would add a measure of realism to their behavior if they could be looking towards the player wherever he happens to be standing at the time of communication. How to do this, though, is a little confusing.
I've been looking at the player DSQ animations, and I see that there are two blend animations, one for looking up and down, and one for looking side to side. These two blended together should accomplish what I need, I believe. I've looked a bit at the freelook code to try to get a feel for it, but the code is a bit confusing. The other issue is that we're not using the classic Kork skeleton, but rather the typical Max biped skeleton.
I assume that the first thing we should do is to create the basic up/down and left/right animations for the skeleton, and make them blend animations.
The question, though, is how to set up the code to move the AIPlayer head to a particular position. Calculating how much left/right or up/down is needed to face the player is not a big deal, but how do you play a particular DSQ such that it moves the head to a particular position within that animation?
Thanks.
I'd like to have the NPC's in my game (AIPlayers) turn their head to face the player when they speak. Since the player can approach the NPCs from a number of different angles, it would add a measure of realism to their behavior if they could be looking towards the player wherever he happens to be standing at the time of communication. How to do this, though, is a little confusing.
I've been looking at the player DSQ animations, and I see that there are two blend animations, one for looking up and down, and one for looking side to side. These two blended together should accomplish what I need, I believe. I've looked a bit at the freelook code to try to get a feel for it, but the code is a bit confusing. The other issue is that we're not using the classic Kork skeleton, but rather the typical Max biped skeleton.
I assume that the first thing we should do is to create the basic up/down and left/right animations for the skeleton, and make them blend animations.
The question, though, is how to set up the code to move the AIPlayer head to a particular position. Calculating how much left/right or up/down is needed to face the player is not a big deal, but how do you play a particular DSQ such that it moves the head to a particular position within that animation?
Thanks.
#2
05/19/2008 (12:04 pm)
Right, that's not the real challenge -- the problem is, how do you play the left/right or up/down animation to a certain point? I can play animations with AIPlayers, but they play from start to finish. How do you get those animations to play only until the head reaches a certain point?
#3
05/21/2008 (2:38 pm)
Any additional thoughts on this?
#4
05/23/2008 (9:35 am)
My first thought was mounting the head and performing calculations based on where the character was, but unless the extents were setup correctly (and able to tell the body to move as well), it could lead to disorienting Exorcist moments when the head seems to spin independently from the body to follow the player. Could be cool in some games...but probably not the effect you're looking for.
#5
mShapeInstance->setPos( thread* animThread, float pos )
I am pretty sure there is not support for setting a position on a script thread (if you are playing your animations as script threads). I have seen a thread or maybe a resource about adding this feature, but basically you will need to do this in C++.
05/23/2008 (11:01 am)
You do most animation thread operations through tsShapeInstance. Look for methods there.mShapeInstance->setPos( thread* animThread, float pos )
I am pretty sure there is not support for setting a position on a script thread (if you are playing your animations as script threads). I have seen a thread or maybe a resource about adding this feature, but basically you will need to do this in C++.
#6
I guess the real problem for me is figuring out how to play only a portion of a head movement animation. The current side-to-side and up-down animations for Kork show the entire motion when they are played. So how does one specify that only certain keyframes of the animation should be played?
05/23/2008 (11:05 am)
True, although there might be a place for a good satanic head animation somewhere in the game...I guess the real problem for me is figuring out how to play only a portion of a head movement animation. The current side-to-side and up-down animations for Kork show the entire motion when they are played. So how does one specify that only certain keyframes of the animation should be played?
#7
05/23/2008 (11:13 am)
Looks like I posted right after you, James. Thanks for the heads up, I'll check it out. Probably won't be too tough to add it in as a script command.
Associate Ross Pawley