Third Person Shooter Movement Example File

[edit] I’m leaving this stuff all here in case someone wants to try to pull it apart and figure out how to make a better version, but it dun broke in one of the recent versions of Blender and I’ve fallen behind on the changes to BGE python so I’m not sure what’s wrong. Pretty sure the last version I confirmed it working in was 2.68a, and as of now (2.75 is the current version while I’m writing) it’s definitely not working. (To get it to stop throwing errors you’ll have to add “import bge” to the top of the Control script, it seems at some point bge stopped being automatically imported by default)

Current latest version: TPS Walk Rig 0.0.61.blend (1.61 MB)

I initially made this for someone in a support thread, but then I kept adding to it and now it’s got enough features that I think it’s worth letting other people to see. Perhaps you guys who are learning python can get a sense for how it might be used in conjunction with animations to make some natural character movement.

The script and rig are a bit messy since I have been adding features as I went, so it may be better to learn individual techniques and methods from this file and make your own cleaner version (or a version that suits your purposes better)

Essentially it’s a demo of how four action channels can be played at once with varied weights to make a character smoothly blend between walking in different directions and going from a walk to a run. It also has a simple rig setup to tilt the camera as the character aims and looks up and down.

I went a little overboard with the comments since I hopefully want it to be something that can be understood by a wider range of people, so apologies if some of the concepts I explain seem a little basic. Conversely, please tell me if something is cryptic or doesn’t make sense (or if you notice I did something stupid or missed something obvious)

I invite you to walk, run and aim, while watching the feet. Notice how if you turn the feet adjust with the turn, and as the character changes speeds the animations blend from a walk to a run.
The controls are the mouse to look around, W, S, A and D to walk, shift to run, right click to aim and left click to fire, tab to switch the camera to the other shoulder.

If you use the script directly in your game, I would appreciate a credit- if you just learn from it then the learnin’ is all yours. The rest of the assets were thrown together in extremely little time so y’all are welcome to 'em. Apologies for the shoddy animations.

[edit] now with a preview video, and a bug fix (forgot to change the action layer test for the shooting when I rearranged the action layers)

Older versions:
TPS Walk Rig 0.0.5.blend (1.55 MB)
TPS Walk Rig 0.0.6.blend (1.6 MB)

2 Likes

Real nize work for me as a Beginner to Python it is realy useful i can learn realy much from it, and i like the wipping of the Char when he stand still it looks like a lil bit insane. ( sry for my Bad english):slight_smile:

Oh yeah, I doubled all the animation speeds somewhere along the line and I forgot to slow the idle animation back down. I’m also working on making variables more accessible right now, so that it’s easier to go in and change animation lengths and such without having to hunt through the script.

Great work as aways Captain.

The animation of him running is weird, it’s look like he’s underwater with a heavy armor or it’s just look like Issac Clark from Dead Space hehe.

How dificult would be to add a feature to change the camera from the left to the right by pressing TAB? It’s a feature from Resident Evil 4, 5 and 6 and left hand ppl sure would love it.

I might make improved animations but this is more about the script than the quality of the animations. The tab thing is a good idea, it would be as simple as making another aim and look animation and using a property to keep track of which one to use. I’ll have to adjust the rig a tad to make the shoulder switch more convenient but I’ll put it in the next version of the file.

Hello
great AND original resource, Captain!
Thank you very much for sharing!
Bye

OMG thank you. i’ve been trying to make an RPG and needed a good 3rd person camera mechanic and this was perfect. thank you so much. ill be sure to give credit and show you some progress. now quick question, is there an easy way to put a model made in makehuman on the bones to replace the boxes or do i need to start from scratch and learn how you set up the rig?

Since the script doesn’t call on any specific bones you can use any rig you want- the specific setup I used with the camera parent and separate pivot are the best way I could think of to handle that, so it may be easiest to delete the rest of the rig and merge those couple bones into your rig, but as long as you have an action looking down and up, and an action aiming down and up, and your walk and run actions all match up (EG the left foot hits the ground on the same frame in every walk and run action, and so on) you can set it up as you please.

I recommend using IK for the legs because the animations will blend together more smoothly (and it’ll make it a lot easier to make a more convincing walkcycle) and don’t forget to keep in mind that in some actions certain bones will override their motion from other actions so it may be advantageous to have some redundancy (for example, one bone to tilt the hands up and down in the aiming animation, so that when the hands move in the shooting animation the bone can keep its rotation without the shooting action overriding it)

If you don’t want to change the rig (I don’t know if makehuman models come with a rig or not) you should be able to just change the names of the vertex groups on the makehuman model to match the names of the bones on my rig (or the other way around) and of course change the proportions of my rig, but it should work just fine. You’ll probably still have to add a bone or twenty- for example, my rig doesn’t have fingers or any face bones to speak of. There’s also no real metarig to speak of so it’s not very ideal for animating with.

Determining what to imbue appropriate for house-cleaning services is delicate. Pervade too particle and you may be perceived as “covenant basement.” Onset too much and you may be seen as a modest value. Consider… http://ogrodzeniakraty.slask.pl/profesjonalne-srodki-czystosci/http://uslugitransportowekrawczynski.pl/torkhttp://krawiecawangardakrosno.pl/tag/zamiatarki/http://www.pogoda-dlugoterminowa.com.pl/promocyjne-oferty-wyjazdow-wakacyjnych-w-europie/http://piekarniazakopianka-sanok.pl/tag/czysciwa-przemyslowe/ http://f.irmy.pl/firma.php?fid=1541&strona=opinie-komentarzehttp://instalacjeociepleniatychy.pl/tag/zamiatarki/http://auto-moto-buschserwis.pl/tag/profesjonalne-srodki-czystosci/http://tanie.edu.pl/tag/szczegolhttp://wczasynawsilubawka.pl/tag/dezynfekcja-rak/

Awesome work, also very cool character for animatic.

a year ago I was asking about animation blending and the best ways to do it, and got a few answers that were somewhat helpful.
but I just went back to making models instead unhappy with those answers. then today I was thinking about this very same set up, and seeing your posts and .blends confirms it.
Thank you very much.

Nice work as aways Captain.

Bullet holes, recoil and the TAB system, very nice.

The recoil is a little high, but I bet you commented the code where we can change it. Didin’t have time to look at it yet.

Here is another idea, a melee atack maybe. Most of the TPS nowaday have it. IT would be awesome.

Just want this to be as complete as possible.

Oh hey yeah, I forgot about melee, I’ll add that to the todo list. I tried to keep all the variables at the top of the script in one area, gathered together by context (so all the movement speed variables are grouped up, all the gun variables are together, etc)
I will probably change weapon variables to properties on the object so a separate weapon switch script need just assign whatever value it feels to those properties. That would allow the weapon handling to be done separately, and people can use their own script for it.

I am also pondering on splitting parts of the script off into functions in a separate script, so something like the animation system can be called by AI characters as well as the player without having to rewrite the script for each. On the other hand I also want to keep this on the simpler side for people who are still getting comfortable with python. Thoughts?

Well Captain,

I think you should separate the script, at least for me, it’s easier this way and everything get organized. Since one can simply open 2 windows to show 2 or more scripts, I think it’s better since one shall not roll up and down all the time to check the code.

Functions is a basic thing on any Programming Language, any one learning Python should know it or will learn, is one of the first things you learn after the basic anyway. Just make sure to explain what is calling what and from where.

It’s your call.

It plays great, and looks amazing.
Don’t forget there are a lot more animations required for a full 3rd person game though.
Some suggestions for further development:

Jump animation
Impact animation(s) for getting hit
Knock down animation*
Crouch animation
Crawl animation*
Die animation(s)
Being dead
Climb on a box
Climb a ladder
Pick something up
Hold a rifle
Aim a rifle
Shoot a rifle
Hold nothing
Hold a torch or lamp
And the hand to hand combat animation someon else suggested.

*I do this by having a [‘stance’] property and a [‘target_stance’] property. When you lie down, or get knowcked down it switches the target stance, if target stance and stance are different it won’t play any other animations. When your knockdown/lie down animation finishes playing (you can use a property linked to the current animation frame, or drive the animation with property) switch the stance.
When you try to get back up, play the getting up animation, and switch target stance again. Once he’s back on his feet set the stance to upright.

This way you can have a different set of walk/run/getting hit/die animations depending on stance and play thenm depending on if he’s crouching, laying down or upright.

This is awesome, i’ve been waiting to see something like this since layer weights was implemented.

I would suggest making a more varied environment as you develop this more though, I made some simple hills and quickly ran into some problems, most notably is the character doesn’t go down hills so well. It’s pretty cool how when you go up hills the character slows down and the animation matches his speed. great stuff man!

Hey Captain Oblivion, Awesome rig. Just to test, I added a ramp and made the rig walk over it. Have you added leg alignment to the terrain? Because it really looks like the feet align to the ramps slope…

Pretty sure there is no feet alignment, you’re just seeing the animation blend from run to walk as he runs up the ramp slowing down a bit, so it looks like his legs are adjusting. Would be really awesome if he does add feet alignment though.

Nice work Captain! I’m looking forward to trying this out with my characters and mocap data.

Updated version! Now the feet snap to the slope you’re walking on. It’s a bit twitchy though. The character also has enough power to climb slopes, and some other tweaks were made (noted in the changelog in the file)

The latest version is here: TPS Walk Rig 0.0.6.blend (1.6 MB) (I’ve also updated the file and video in the first post to match)

I haven’t done anything to match the feet to the angle of the slope, and the way I coded it means the rig needs to be a little more specialized (I couldn’t come up with a way to make it work with basically any rig)