Root poses...image states...Player animation... Oh My!
by Mark Miley · in Torque Game Engine · 11/05/2003 (3:59 pm) · 6 replies
I've been searching through the forums trying to find information on this and have learned quite a bit, but I'm still running into some problems and confusion. My game is a side scroller so the it's a 3rd person cam sorta.
What I am trying to do essentially is have different root poses while holding different weapons. And then have different recoil states when firing different weapons. As an example: Standing with a pistol weapon or firing with a pistol weapon is going to look different then standing with a rocket launcher or firing the rocket launcher. Now the different recoil stuff I think I figured out. In the weapon image I noticed the light recoil and I changed the light recoil animation to a new one and got it to work with the weapon. Now I also found the the recoil enum in the player.h and player.cc and it looks rather simple to add new recoil states and get them referenced in the player sequences.
Now my problem is the multiple idle states for the different weapons. What I tried doing (which seems like a bit of a hack) was to add a line in my new weapons image datablock.
Now the new line references a function below it that then plays a my new idle animation using the playthread command. I'm not sure if I'm off in the complete wrong direction on this one or not, but it won't play my new animation which is really just an upper body animation for a new placement of the arms. It's not a blend animation. Now the animation shows correctly in the show tool and I can add a new thread...and play the new idle animation on that thread and it looks great, but I can't get it to go using the playthread command which worked for other animations i've done. I'm not sure exactly what I'm doing wrong or if there is a different way to do what I am doing. I have read many, many forum threads on the animations system trying to figure it all out, but it really has me at a standstill as far as adding new animations and getting them to work. I've read the documentation several times as well. I feel I understand the basics of bringing in a new character, changing the default animations and to some extent adding new ones and scripting them, but I'm not sure if I fully understand it. Anyone have any insight or advice on adding multiple root poses or scripting new animations into the game. Ideally I am trying to stay away from the C++ code as I am not that good of a coder and don't understand how they have stuff coded out at all. It seems like I should be able to do what I want through script, but I think I might be going in the wrong direction.
Sorry for the long post...hope someone will read it and that it made any sense. :) Thanks.
What I am trying to do essentially is have different root poses while holding different weapons. And then have different recoil states when firing different weapons. As an example: Standing with a pistol weapon or firing with a pistol weapon is going to look different then standing with a rocket launcher or firing the rocket launcher. Now the different recoil stuff I think I figured out. In the weapon image I noticed the light recoil and I changed the light recoil animation to a new one and got it to work with the weapon. Now I also found the the recoil enum in the player.h and player.cc and it looks rather simple to add new recoil states and get them referenced in the player sequences.
Now my problem is the multiple idle states for the different weapons. What I tried doing (which seems like a bit of a hack) was to add a line in my new weapons image datablock.
stateName[2] = "Ready"; stateTransitionOnNoAmmo[2] = "NoAmmo"; stateTransitionOnTriggerDown[2] = "Fire"; stateScript[2] = "onReady"; //new line
Now the new line references a function below it that then plays a my new idle animation using the playthread command. I'm not sure if I'm off in the complete wrong direction on this one or not, but it won't play my new animation which is really just an upper body animation for a new placement of the arms. It's not a blend animation. Now the animation shows correctly in the show tool and I can add a new thread...and play the new idle animation on that thread and it looks great, but I can't get it to go using the playthread command which worked for other animations i've done. I'm not sure exactly what I'm doing wrong or if there is a different way to do what I am doing. I have read many, many forum threads on the animations system trying to figure it all out, but it really has me at a standstill as far as adding new animations and getting them to work. I've read the documentation several times as well. I feel I understand the basics of bringing in a new character, changing the default animations and to some extent adding new ones and scripting them, but I'm not sure if I fully understand it. Anyone have any insight or advice on adding multiple root poses or scripting new animations into the game. Ideally I am trying to stay away from the C++ code as I am not that good of a coder and don't understand how they have stuff coded out at all. It seems like I should be able to do what I want through script, but I think I might be going in the wrong direction.
Sorry for the long post...hope someone will read it and that it made any sense. :) Thanks.
About the author
#2
11/06/2003 (7:11 am)
Ok. I have been looking through the player.h and player.cc files. Now should my changes be made there or do I need to look deeper? The actionlist seems to be what I'm looking for, but I'm still new to the engine and not sure what is required to have the root sequences recognized.
#3
11/06/2003 (7:50 am)
I think I have it, but I have a question to see if I'm in the right direction here. After looking at Erik Madisons resource on adding swimming and crouching animations it seems like I could add the animations into the actiondef enum and then setup which one is to be used under the player::pickactionanimation(). Now in order to do that I would need to know which weapon the player is currently carrying and then set the appropriate action animation (one of my new ones) based on that. Now my question is this. Is there any way in the c++ code to figure out what weapon the player is currently using? Or would I setup some global variables in script that would be changed based on say a weapon on use script? Then I could reference that in the C++ code. Now how would I do that? Just a hint in the right direction. Thanks. :)
#4
Good luck!
11/06/2003 (8:59 am)
You're going to need to learn about ShapeBase and ShapeBaseImages; the former is a parent class of Player and the latter is used to do weapons. Once you understand how that works, you should be able to get pickAnimation working.Good luck!
#5
Now my question is if I setup a global variable in script...say in the weapon.cs file, can I change that variable in my individual weapons cs file(ie rifle.cs)? What I did with the switch block compiled fine, but it's not having the desired result. What I am doing is adding a statescript[1] = "onactive" into my weapons state section for activate and then adding the function below it where I set my $weaponselect = 1 (or whatever number I have associated with that weapon. I setup the new animations into the actionlist enum and tried a test. Now I am wondering if $weaponselect will always be what I set it to in the weapon.cs file. Should I set the variable in a different cs like an init file? Or am I just on a complete wrong turn here? Thanks for all your help thus far.
11/07/2003 (11:40 pm)
I've been doing allot of study of the files in question and I have another question. The way I have it right now(which might be sloppy) is to essentially have a switch statement on the if(ismount()) section of the pickactionanimation function of the player.cc. The switch statement accesses though a console function a variable stored in script and uses that for the case statements in the script. Then based on that number sets the appropriate actionthread for the new weaponroot anim.Now my question is if I setup a global variable in script...say in the weapon.cs file, can I change that variable in my individual weapons cs file(ie rifle.cs)? What I did with the switch block compiled fine, but it's not having the desired result. What I am doing is adding a statescript[1] = "onactive" into my weapons state section for activate and then adding the function below it where I set my $weaponselect = 1 (or whatever number I have associated with that weapon. I setup the new animations into the actionlist enum and tried a test. Now I am wondering if $weaponselect will always be what I set it to in the weapon.cs file. Should I set the variable in a different cs like an init file? Or am I just on a complete wrong turn here? Thanks for all your help thus far.
#6
Has any been found? Tried looking through the resources but didn't find anything.
06/28/2006 (1:17 am)
I was just looking for a solution.Has any been found? Tried looking through the resources but didn't find anything.
Associate Ben Garney
To do this sort of significant change you're going to need to do some C++ hackery, unfortunately. Although it isn't too painful of a change, as changes go. :)