Guns firing and character walking at the same time
I want my character to be able to walk and fire his gun at the same time, which seems simple. But I want his gun to kick, and have the slide pull back whenever you fire, without him breaking stride.
This presents a problem because there's no way to know what frame of the stride you're going to be on when the player fires the weapon.
So my first solution was to have a second walk animation where the guys hands are in the air as if he's holding the gun, (I can live without his body reacting to the kick of the gun for now.) Then I had another object which would be the gun and it's animations. So whenever you press fire while you're walking, the gun will kick up, the slide comes back, bullet is created at a position relative to the gun object.
The trick is, I have the gun repositioned based on the frame that the walk cycle is in.
The problem is it's not working out so well. I think my numbers are solid, I went into the object editor, zoomed in as far as I could and drew graph lines from point to point and counted the distance through x and y. I played it in the game. The gun is indeed moving each frame, but all around the guy's hand. And I'm wondering if maybe the computer just can't keep up with the animation. Should this be done with a fast loop? Or is there a much smarter hassle free way to do this with even better results?
Re: Guns firing and character walking at the same time
have the entire upper body separated from the legs? i think this is how it works in a game like Contra for example. when the player shoots you can play a shoot animation on the upper body while the legs are still moving independently.
using built in movements i used to have trouble with 2 objects following each other perfectly, but making custom movements seems to get rid of that problem.
Re: Guns firing and character walking at the same time
I'm using the custom movement from the fast loop tutorial on this site. I'm going to do some experiments with the upper body like you said with some simpler objects. Game is getting pretty complicated, could be other forces at work here, lol.
If anyone else reads this, more advice is very welcome.
EDIT:
I feel silly. Now that I've given it a bit of thought, having the upper body as a second object instead of starting at the guns would allow me to not only animate the body reacting to the shot, but I wouldn't even have to mess with nudging it on every frame through coding. Pft, lawl.