• Runtimes
  • Frame by Frame animation using code

Let me explain my situation. I am making a 2d platformer "run and gun" style game. At the moment, my character will do its "run" animation and I then use code to overide the arm bones that hold the gun. This way The run animation plays at all times while the arms of the character can be adjusted to point towards the direction that the player is pushing the joystick towards. (For aiming the gun).

The problem is that doing this makes the arms look very frozen and not very natural when rotating. (Because both arms just rotate about the shoulders, the forearms and upper arms stay at the same angle).

To make the animation look more natural, I will have to do some pretty serious code to adjust bone angles of all the bones in the arms depending on the angle the joystick is being pushed. (having the gun straight up in the air would have the arm bones scrunched tight together. Having the gun straight in front of the player the arm bones would be more open in their angles).

My Question: Is it possible to control an animation frame by frame using code? (move forward a frame, move back a frame, find a frame, pause)
If this is possible, then I could do the actual animation of the gun from it pointing down to the ground and all the way up high above the players head. Then depending on where the player is pushing the joystick in game, I could display the frame of that animation that shows the spine skeleton pointing its weapon in that same direction.

Hope that made sense.... Any thoughts are appreciated and very helpful!

  • تم التحرير
7 أيام لاحقا

You can take a look at the Super Spineboy game demo we did for A MAZE. We pretty much what you're looking for there. You can find it here https://github.com/EsotericSoftware/spine-superspineboy

To sum it up, we have an animation for shooting and mix that in the run, and jump animations when shooting.

Instead of setting your arms to exactly point at the mouse, you can mix some small amount of rotation from whatever the arms would otherwise be doing. Eg, if you need to rotate a bone X degrees from the walk/jump/whatever animation pose to point at the mouse, rotate it that much minus X * 0.05.

شهر واحد لاحقا

@Shiu,
I checked out teh super spine boy demo, but it is different in the fact that the spine boy only has 1 bone for his arm / gun. My character has 2 bones, and upper arm and a fore arm. Still haven't been able to make this work out well =(

Spineboy has 3 bones for his arm and hand/gun:

Image removed due to the lack of support for HTTPS. | Show Anyway

What exactly is your problem?