Im working on a game that runs like MegaMan, (run, jump, shoot) an Ive done all the basic stuff (the movement engine, enemies, etc), but I just need a megaman-style shooting engine, that lets you shoot while running,jumping etc.
I cant really explain what I need, but I need to copy the shooting engine that the megaman games use, where, for example, when Megaman is walking, and the player pushes 'shoot', Megaman sticks his arm out and shoots, but his walking animation doesnt appear to change or get interrupted at all. His legs and left arm are still moving in time.
The only thing that changes is his right arm, which is held out while shooting, and when thats over, Megaman resumes his walking animation. Same goes for jumping, falling, standing, etc.
I once had a Megaman X style tutorial for TGF that worked like that, but that was ages ago, on my old computer. Now, the file is gone from the site, and thats not much use.
Ive tried to copy it, but I cant remember how they did it. So I tried my own techniques. One of them was having the right arm as a SEPERATE object, but that doesnt work, because it doesnt seem to 'stay in place' when the character is moving. And it cant stay in sync with the characters animations either.
I had another technique, but I cant remember it. I just remember it not working.
So... can anyone help me with that?
(I have a feeling that no-one gets exactly what I mean)
The best way to to do this is with a separate object for the arm, and I guarantee you that's how you saw it done. Yes, it will lag behind if you're just using:
-Arm: set position to (0,0) from Character
So don't do that. Instead, have a custom movement engine (which you'll need for megaman to move properly anyway) and just move the arm object whenever you move the character object.
Yeah, Im using a custom engine anyway. But Ive tried that technique, and even If i can keep the arm 'attached' the arm's animation wont stay in 'sync' with the body. But thanks. It never really occurred to me to use a custom engine for the arm aswell.
And the Megaman X engine I once had used another technique. It had the different shooting animations in different directions or something.
I can't imagine why the animations wouldn't remain synchronised. Apart from after a shooting animation when it returns to the striding animation, I guess. In that case try this:
(assuming the gun is currently in its 'shooting' anim and you want to return to 'running,' the legs are in their 'running' animation)
Current frame of Legs = 0
--Gun: change animation sequence to running
That way the arm will stay out until the legs are back to their first frame before going back into the running animation, so they should both start on frame 0 of the animation at almost exactly the same time.
I think the animtions are even trickier to keep synced than keeping things movings synced. The problem is apparent if you think like this:
say there is 3 frames for the legs moving and 3 for the arms, they will match fine normally, but then when the arm changes to 'shooting' it will not affect the legs at all. Then when not shooting the arm will start 'walking' again but the legs may be at animtion frame 1 2 or 3. Its a one in 3 chance they will match.
With your custom movement in use, you could have your standard animations mixed with directions. In other words, use left and right for the animation in standard mode ; while using diagonal directions for the shooting animations.
Here is how :
repeat while moved left
& flag 1 is off -set direction left (standard animation)
repeat while moved right
& flag 1 is off -vise versa (running for example)
When press fire 1 - set flag 1 on, and shoot
Flag 1 is on - add 1 to value A
Flag 1 is on & direction is (right) - set direction to up/right. e.g. running while shooting
Flag 1 is on & direction is (left) - set direction to up/left.
Value A is > 30 - set flag 1 off, set value A to zero.
It will work because the animation number is only reset when you change animation sequences - not direction.