Walk and Chew Gum Conundrum
by Steve Acaster · 08/06/2008 (9:44 am) · 9 comments
Actually run an aim-down-sight animation so that when the player looks up and down it aligns correctly with the eye node. It ain't as straight forward as it sounds...
This counts as multi-tasking, as does walking and chewing gum. Multi-tasking seems a big thing in the games development industry - which kinda makes you wonder why there aren't more women working in it.....
As a one-man dev machine, multi-tasking is rather essential, regardless of the average male's inability to perform it. The average male in this case is my player/ai model.
I mean ... how hard can it be?
NOTE: I'm using a custom, scratch built model and armature set, so I've got to come up with all custom animations, my rig isn't compatible with Blue/Orange Guy setups or anims. If you're scratch building player models yourself -- you might find the info below useful. Ignore the terrible hands on my models.
So what I needed was an aim anim - easy enough, boot-up Blender, align eye, mount0 and where the weapon sight would be. Then it's a simple case (it wasn't) of having my aim anim play over the blended look animation. And this is where it all went wrong.
My aim aligns fine in the root along the horizontal, and it aligns fine at the extremities of the look anim (that's up and down for real people), it's just the bits in between where the aim wandered out of alignment. Unfortunately that makes up 160 degrees of 180. Ah....
There appeared to be a disparency between the angle of looking and the speed at which the animation plays, it's just not a constant speed as the mouse moves. It's quicker at the 45 degree angles than the 90s where it slows down. Time consuming trial-and-error tweaking of my look animation was called for, but it soon became apparent that wasn't going to work - or if it was, it wasn't going to work this decade.....
So here's a tip, for anyone trying to align the look animation to the actual up-down speed of the mouse movement. Go into Player.cs and find this bit.
MinLookAngle is up (Negative Number)
MaxLookAngle is down (Positive Number)
and MaxFreeLookAngle does exactly what it says on the tin. Ignore this.
For Min/MaxLookAngle zero is horizontal level, the centre of the screen, -/+1 is 90 degree up or down, literally vertical. So a 45 degree angle is -/+0.5 and each 0.1 is 9 degrees - so technically you could use that as a guide for your look anim -- except the rotation speed isn't constant when moving the mouse to look up and down - so you can't. Hence the problems in the first place.
When aligning aim and look animations, having the crosshair visible is a must, you need to know the centre of the screen. And remember, in you look anim, you can't adjust any bone that you moved for the aim anim, because it'll start messing with them and that will put your aim off.
1: Set both LookAngles to 0. This prevents any vertical movement. Check your aim anim is aligned - if it isn't here it won't be anywhere.
2: Next set your furthest look down on both Min and Max. +1 is 90 degrees down, I set mine to 0.7 (63 degrees) just to stop the player shooting himself in the foot. Check the animation aligns, if it doesn't, tweak as neccessary until it does. Repeat for the up angle (-1 for 90 degrees, -0.8 for 72 degrees, -0.7 for 63 degrees, you get the idea).
3: On my blended look animation, level/horizontal is set at frame 8. Fully up is 1 and fully down is 15. This gives a value of 7 frames either way, an odd number so I can find the middle of the animation sequence. I stuck an animation key here and technically that's 45 degrees regardless of your whether your Min/Max value is 1.0 or 0.7.
4: Check the alignment and tweak as neccessary until it lines up. And that should do it.
I did cause myself a few extra problems. Having a single bone to the spine just wasn't going to cut it and I reckon at least 2 are a must. And of course I wanted a fairly nice third person aim too.
Over-the-shoulder-cam for that Gears of Yorkshire vibe
The crosshair only shows up when the player aims and is in Third Person view. In both First and Third person the HUD (in my case currently just the health bar) disappears to give a clearer and less distracting view and the camera zooms in dependant on what weapon is being used.
Obligatory poor quality YouTube vid of it all in action
It all took a bit longer than planned --- though considering everything takes longer than planned it probably took just the right amount of time. There are many techniques available to make life easier in developing with Torque (TGEA1.7.1) - it's just a question of finding them.
Now, back to urban content creation like I was supposed to be doing before I got distracted by animation tweaks.
edit: disparence isn't a word, it's disparency
This counts as multi-tasking, as does walking and chewing gum. Multi-tasking seems a big thing in the games development industry - which kinda makes you wonder why there aren't more women working in it.....
As a one-man dev machine, multi-tasking is rather essential, regardless of the average male's inability to perform it. The average male in this case is my player/ai model.
I mean ... how hard can it be?NOTE: I'm using a custom, scratch built model and armature set, so I've got to come up with all custom animations, my rig isn't compatible with Blue/Orange Guy setups or anims. If you're scratch building player models yourself -- you might find the info below useful. Ignore the terrible hands on my models.
So what I needed was an aim anim - easy enough, boot-up Blender, align eye, mount0 and where the weapon sight would be. Then it's a simple case (it wasn't) of having my aim anim play over the blended look animation. And this is where it all went wrong.
My aim aligns fine in the root along the horizontal, and it aligns fine at the extremities of the look anim (that's up and down for real people), it's just the bits in between where the aim wandered out of alignment. Unfortunately that makes up 160 degrees of 180. Ah....
There appeared to be a disparency between the angle of looking and the speed at which the animation plays, it's just not a constant speed as the mouse moves. It's quicker at the 45 degree angles than the 90s where it slows down. Time consuming trial-and-error tweaking of my look animation was called for, but it soon became apparent that wasn't going to work - or if it was, it wasn't going to work this decade.....
So here's a tip, for anyone trying to align the look animation to the actual up-down speed of the mouse movement. Go into Player.cs and find this bit.
minLookAngle = -1.4; maxLookAngle = 1.4; maxFreelookAngle = 3.0;
MinLookAngle is up (Negative Number)
MaxLookAngle is down (Positive Number)
and MaxFreeLookAngle does exactly what it says on the tin. Ignore this.
For Min/MaxLookAngle zero is horizontal level, the centre of the screen, -/+1 is 90 degree up or down, literally vertical. So a 45 degree angle is -/+0.5 and each 0.1 is 9 degrees - so technically you could use that as a guide for your look anim -- except the rotation speed isn't constant when moving the mouse to look up and down - so you can't. Hence the problems in the first place.
When aligning aim and look animations, having the crosshair visible is a must, you need to know the centre of the screen. And remember, in you look anim, you can't adjust any bone that you moved for the aim anim, because it'll start messing with them and that will put your aim off.
1: Set both LookAngles to 0. This prevents any vertical movement. Check your aim anim is aligned - if it isn't here it won't be anywhere.
2: Next set your furthest look down on both Min and Max. +1 is 90 degrees down, I set mine to 0.7 (63 degrees) just to stop the player shooting himself in the foot. Check the animation aligns, if it doesn't, tweak as neccessary until it does. Repeat for the up angle (-1 for 90 degrees, -0.8 for 72 degrees, -0.7 for 63 degrees, you get the idea).
3: On my blended look animation, level/horizontal is set at frame 8. Fully up is 1 and fully down is 15. This gives a value of 7 frames either way, an odd number so I can find the middle of the animation sequence. I stuck an animation key here and technically that's 45 degrees regardless of your whether your Min/Max value is 1.0 or 0.7.
4: Check the alignment and tweak as neccessary until it lines up. And that should do it.
I did cause myself a few extra problems. Having a single bone to the spine just wasn't going to cut it and I reckon at least 2 are a must. And of course I wanted a fairly nice third person aim too.
Over-the-shoulder-cam for that Gears of Yorkshire vibeThe crosshair only shows up when the player aims and is in Third Person view. In both First and Third person the HUD (in my case currently just the health bar) disappears to give a clearer and less distracting view and the camera zooms in dependant on what weapon is being used.
Obligatory poor quality YouTube vid of it all in action
It all took a bit longer than planned --- though considering everything takes longer than planned it probably took just the right amount of time. There are many techniques available to make life easier in developing with Torque (TGEA1.7.1) - it's just a question of finding them.
Now, back to urban content creation like I was supposed to be doing before I got distracted by animation tweaks.
edit: disparence isn't a word, it's disparency
About the author
One Bloke ... In His Bedroom ... Making Indie Games ...
#2
I know this thread is not about over-the-shoulder camera view, but do you know of a resource that explains how to do it?
Thx!
- BigPapa
08/06/2008 (11:57 am)
Looking good! I will have to review this thread once I get to the same point as you with aim.I know this thread is not about over-the-shoulder camera view, but do you know of a resource that explains how to do it?
Thx!
- BigPapa
#3
I always thought the min/max look angle values were in radians - so pi/2 is 90 up/down.
08/06/2008 (12:07 pm)
Your game's coming along nicely :) I'm just about to get into all the aiming and weapon sight stuff, though I think I'll just sidestep your problem entirely - each weapon has two arm nimations, one for holding at the hip, and one for aiming. Each of these animations goes up/down.I always thought the min/max look angle values were in radians - so pi/2 is 90 up/down.
#4
@Daniel - Radians? Isn't that what you get from too many chest X-rays? I'd like my name removing from that joke.... :D
08/06/2008 (1:09 pm)
@BigPapa - I think there is a resource for over-the-shoulder view (possibly Advanced Camera?), but to be honest I just put the cam node of my rig to the side of the model instead of directly behind.@Daniel - Radians? Isn't that what you get from too many chest X-rays? I'd like my name removing from that joke.... :D
#5
08/06/2008 (1:21 pm)
I find it hard to follow wordplay of that calibre ;)
#6
Then you just need to align the "view" model with the camera and youre done.
08/06/2008 (4:06 pm)
Or alternatively, you could do what every other FPS game does and simply model a set of arms and weapons and only show those in first person (then disabling the player model too).Then you just need to align the "view" model with the camera and youre done.
#7
Yeah I did think about that (I had an unsuccessful job interview as a mission scripter with Treyarch for COD5 last year and saw that the hands come with the weapon and the arms get added later), but I rather like having the body of the model available in-game (for shadow and checking where your feet are - though not shooting them) I thought that the constant swapping of weapons would be more trouble than it was worth. If I was still working with TGE1.5.2 I'd stick with the weapon-offset resource I was previously using.
Sort of thinking about having all my "gun" weapons fitting one animation system and "melee" fitting another (not that I've even touched on that bit yet). I'm not C++ conversant (my degree's in oil painting - I smell of turps), so I just script and use resources in code from the GG community (e.g. pathfinding).
PS: Hull City for Premiership glory!
(english joke - apologies to all other nations)
08/06/2008 (5:12 pm)
Howdo, Phil. Yeah I did think about that (I had an unsuccessful job interview as a mission scripter with Treyarch for COD5 last year and saw that the hands come with the weapon and the arms get added later), but I rather like having the body of the model available in-game (for shadow and checking where your feet are - though not shooting them) I thought that the constant swapping of weapons would be more trouble than it was worth. If I was still working with TGE1.5.2 I'd stick with the weapon-offset resource I was previously using.
Sort of thinking about having all my "gun" weapons fitting one animation system and "melee" fitting another (not that I've even touched on that bit yet). I'm not C++ conversant (my degree's in oil painting - I smell of turps), so I just script and use resources in code from the GG community (e.g. pathfinding).
PS: Hull City for Premiership glory!
(english joke - apologies to all other nations)
#8
08/06/2008 (5:26 pm)
Nice work, and thanks for sharing what you found out :-)
#9
I'd like to congratulate you, Steve, for doing exactly not that. :P Nothing wrong with your suggestion, Phil - it's just a personal thying I have with view-entities :P
"Sort of thinking about having all my "gun" weapons fitting one animation system and "melee" fitting another"
That's the approach I'm taking.
08/06/2008 (11:52 pm)
"what every other FPS game does"I'd like to congratulate you, Steve, for doing exactly not that. :P Nothing wrong with your suggestion, Phil - it's just a personal thying I have with view-entities :P
"Sort of thinking about having all my "gun" weapons fitting one animation system and "melee" fitting another"
That's the approach I'm taking.

Torque Owner Dusty Monk
Windstorm Studios
g'luck man!