A Design Quandary
Miscellaneous Forums/General Discussion/A Design Quandary
I'm having a spot of ambivolence about handling characters walking on slopes. My game doesn't have a lot of slopes, but I'd still like the engine to handle them properly so that it can if and when I want to.
When a character is standing on a slope, his feet go through the floor. There's not much I can do about it. I can't do about 40 or 50 versions of each animation ( around 120 ) to account for every conceivable angle within a few degrees, so his feet are always going to go through the floor. More at some angles than others,of course. When he's facing up the hill and moving up the hill it's not too bad, when he turns sideways, as in the picture below, it is quite noticeable ( although obviously I've zoomed in and put the camera at an unnatural angle to show it here so not quite *this* obvious.)

Now the only other thing I can do is rotate the character as he walks to match the slope beneath him. But that's not strictly natural, is it? When you walk up a slope, you don't lean back to keep yourself perpendicular to the slope of the path, do you? ( Or in the case of the picture here, lean to his right as he walks along the slope. )
So I'm really stuck with those two options. I can avoid the visual errors but create something which is somewhat unnatural, or I can follow reality and create something with visual errors. What's the preferred option here?
Forget about it - nobody will care.
Many developers let this one slip through as it is not worth fixing.
You can cheat (depending on what camera angles you use) by elevating the character so that the 'sunken' foot is above ground - technically, the other is in mid-air, but (depending on camera angle) nobody will notice - or care. Collision pivots to the tootsies is the way to go.
You could also bury them in short grass to dampen the effect, or make little dust clouds when turning on pathways... But to be honest, I recall a few games have that problem, and some not even on the feet, e.g. weapons not part of the collision detection when a character walks up to a wall.
Unfortunately, burying them in grass isn't really an option. He's more likely to be walking up a concrete ramp than a grassy knoll.
You're probably both right that I'm overthinking this. It probably doesn't matter either way. I think I'm beginning to develop OCD in my old age, didn't realize until now that it was contagious.
Unfortunately, burying them in grass isn't really an option.
Ahhh, never mind... a brain storm is a brain storm, and 9/10 times they are bloody useless anyway! ;)
I guess you have to give your character bendable knees and ankles and use bones so that you adjust his foot Y position based on the slope, and position the feet appropriately so that it looks convincing.
What we do at work is shoot 2 rays under each ray to know the ground's location and then adjust both feet and knees using IK. If they are deformed meshes and not skeletal animations, you are pretty much screwed.
Unfortunately, writing an IK solver isn't an option. I'm not remotely confident enough in the way the 3D engine in question handles skeletal animation as it is. 95% of my wasted time has been coding around bugs, and questionable features in the handling of skeletal animation. I'm almost certain that one of these "questionable features" makes it impossible to control the bones as you would need to in any case.
This is the kind of thing beginning developers will obsess over even though every single game on the market just doesn't worry about it.
Make the player lean back as they run up it? Some games do that. Only problem is when they are standing one foot on the slop, and one off. Otherwise as Puki says forget it (the perfection in me screams "Nooooo") but I've seen tons of top level games with crappy polyon clashes like that.
If you want to improve the look you could position the character up a bit instead of where you've got it in that pic, so that the foot isn't going through the ground.
Yep, the industry has looked at this time and time again - it is just not worth programming around it. It is unusual for a game to focus on a character's feet. People will probably notice - but nobody will care.
One solution could be to put every character in full-length dresses/skirts. However, that would look stupid.
Didn't play it myself yet, but the first game which I know of to use IK and animation blending to solve the problem is GTA IV (or at least it was marketed this way in the previews). Most games don't even care about other more noticeable aspects (it took developers some time even to resolve basic issues like the camera in 3rd person games, where the player always pivoted in front of the view instead of having the camera rotate around a standing character... even Oblivion uses the former method).
It's done in most nintendo's 3d games, check zelda, mario etc. Most dev's don't care about such details in most games but it doesn't seem something that is remotely difficult for them to add.
Why not create a ragdoll of the hips and legs and place them at your player, do a raycheck and adjust each foot accordingly then align the bones of the player to the ragdoll.
This is the kind of thing beginning developers will obsess over even though every single game on the market just doesn't worry about it.
I've seen quite a few games on the market which have solutions for this. A recent game would be CoD4. I believe Quake 3 and 4 also have it solved. GTA has it solved, but then it uses Naturalmotion's Endorphin to create physical behavior for the whole body.
If it were my game, to save time I'd work the levels so all the walkable parts were flat. Providing the rest of the environment is interesting, people usually don't care if the area the characters are walking on is completely flat. It's not the end of the world having guys clip through sloped floors, but it can be a red-flag for budget development (since properly standing 3D characters have been present in games for the last five or so years). That's my two cents, anyway :)
Gabriel, are you refering to tv3d regarding the skeletal system, is that poor?
I guess this won't be an option for you but physical characters could do it properly. If you can't deal with IK then you could try to minimize the error with something like a general standing on slope animation phase - or a small set for instance - and/or tweaking the camera for such situations. There are several others tweaks you could do for a comic like represantation but the way the image looks, i don't think they would fit in here. You also don't notice it this much when you're moving fast... ;O)
I've implemented it both ways, and I can change it with a constant, so I'll just wait until I release it in beta and see what people think. Reactor's idea about keeping the walkable area flat and allowing the non-walkable areas to be raised to add interest was how I originally planned to do it, and I think it's 95% certain that it would stay that way, but I wanted the engine to be ready if I changed my mind.
I am referring to TV3D, and as for whether it's poor, my knowledge of matrix mathematics is perhaps too poor for me to be the person to judge. The forums are full of people trying to do IK or custom animation mixing by manipulating the bone matrices, and I can't find one who has it working. So either it's that bad or we're all too stupid to do it. If it was just me, I'd be leaning towards stupid. Of course, this is only an issue because TV3D has far more power and speed in its animation system than any other I've seen. As I said to someone who asked me about this yesterday, I could spend two years starting over with a new 3D engine and then have twice as many problems in that engine. TV3D is the worst 3D engine out there except for all the others.
So I'm afraid I ( and you if you ever play the game ) am going to have to live with one of my compromise options.
I guess you'll be fine with it this way then.
Well, at least unless your game ins't about somekind of military shoes skid resistance competition.