I'm designing a simple fps shooter , and in the past few days I've tested it only with a .md2 model of a chaingun ( the gun with rotating tubes).
In order to make the gun rotate , I used this simple code instead of using a event receiver:
if(GetAsyncKeyState(VK_CONTROL) != 0)
weapon->setAnimationSpeed(200);
else
weapon->setAnimationSpeed(0);
Of course , this code only works in windows , but for me that's not a problem , and it works just perfectly for the chaingun , that has such a simple rotating-only animation.
Lately I added new weapons , like a rifle with a more complex shooting animation ( shoot + reload ), and I found out that this code is not very reliable , because it makes the animation play while the key is pressed , and it stops it IMMEDIATELY after releasing the key. I'd want the animation to play from the beginning of the end just pressing the key once.
How can i make it ?
Please remember that the code above is included in the
while(device->run()) { }
loop , so the instruction are read every time the engine refresh the screen.
I also thought about defining a counter , like :
s32 i = 8; //8 is the first frame of the shooting animation
and icrement it every loop of the while :
i++;
weapon->setFrameLoop(i,25); // 25 is the last frame of the animation
if(i > 25)
i = 8;
//and so on...
I don't think there's a problem in not using the event receiver , because my GetAsyncKeyState routine makes the same thing , in a more basic fashion, and the problem is indipendent from how the keyboard input is received.
Please , help me
Thanx
weapon animation loop
1) I usually program in plain c ,using sockets in linux ( I study telecommunications ) , so I'm not very good with OOP ,therefore I prefer to avoid using too many classes. But that's not the problem . I WILL use the event receiver , but only when I will succed in making the animation work the way I want to .
And as I wrote before , I'm quite sure there is no connection between using a different input routine and the problem I have. I just want to keep it simple for now that i'm learning to use the engine.
2) I posted only the code I use to start the animation , the animator is defined earlier in the code , as well as the animation name ( wich of course becomes useless if I use setFrameLoop , but I will not , that was just an idea.)
And as I wrote before , I'm quite sure there is no connection between using a different input routine and the problem I have. I just want to keep it simple for now that i'm learning to use the engine.
2) I posted only the code I use to start the animation , the animator is defined earlier in the code , as well as the animation name ( wich of course becomes useless if I use setFrameLoop , but I will not , that was just an idea.)
from reading your post quickly I think your in need of a little modification I made to Irrlicht. It allows you to set whether or not an animation will loop AND if the animation is set to not loop it will call a user defined callback when the animation finishes.
details here http://irrlicht.sourceforge.net/phpBB2/ ... bc652a31f7
details here http://irrlicht.sourceforge.net/phpBB2/ ... bc652a31f7
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
Crucible of Stars
Crucible of Stars