Jump to content

Character aiming


Recommended Posts

Hello guys! I've just start developing new side-scroller shooter game and I've encountered first issue. I need solution for animated character aiming. Characer is animated with multiple spritesheets (one for legs and torso, one for head, and two for arms). My current solution is to set anchor points for arms and head and then rotate sprites by mouse coordinates. Problem for this solution is that when character is running torso is moving up and down resulting moved anchor point. I can set different anchor point for each frame, but that would be impractical and hard to achieve. Especially having lots of different characters.

There's current state: https://gugis.github.io/platformer/ (move your mouse to aim, anchor point for arm of first character is updated every frame, so it looks better than second character).

And there;s example of what I want to achieve: 

 

I was researching tools like Spine, Spriter and etc. But there's no Phaser implementation (or documentation) for manipulating bones by  code. Also these tools are not free and I can't afford them at the moment. What would be the best solution for current situation. I will be grateful for any tips.

Thank you!

Link to post
Share on other sites

Disclaimer: I don't have much personal experience with either animation or phaser, just sharing some thoughts :)

Looks like you're trying to achieve what is done best with skeletal animation. There are actualy few free tools for that. The most known is DragonBones I think. Another interesting one that I recently saw is Nima web-app. Although I've only (superficially) tried the first one, so can't tell anything about manipulating bones.

On the other hand,

Quote

 Problem for this solution is that when character is running torso is moving up and down resulting moved anchor point.

For me it sounds like the way anchor points are supposed to work. Looking at your demo I see that there's an issue with head and arms moving not up and down when rotated, but left and right. Also would be nice to add to screen some debug info (bounding boxes, anchor points) to see more clearly what happens there.

Might look closer at the code if I have more time, just guessing now: you're now rotating objects themselves, right? Can you instead rotate object graphics? More general: you probably want to somehow make movement more independent from rotation since now they are affecting each other in the wrong way.

Hope this helps :)

Link to post
Share on other sites

When considering your spritesheets and your own solution I would say that it looks fine right now by manually setting the pivot points manually. Your character motion looks very realistic (I guess thats why you have those seperates sheets) thats nice, but also makes it more complicated. The only solution I could think of is to use lock constraint in P2 physics to mimic  a skeleton. I came up with an example of a possible solution for you:

http://54.87.189.59/example3/

In the example I used the lockConstraint feature of P2 physics to create a simple custom skeleton. In your case it might be possible to use the same skeleton, but instead of using single sprites, just attach the entire spritesheet of each bodypart. I did not include the legs, but I would add the legs seperately (but then you would have to redesign your torso_running.png spritesheet) OR you might just be able to replace the torso in my example with your own torso_running spritesheet (ideally).  

You could also discard the spritesheets that do not have a lot of motion (In particular your head and arm spritesheets don't move that much in your sheets) and make a single atlas with the head and arms and torso and try to mimic the motion by playing with physical properties of each bodypart (mass, inertia etc..). But that is probably a downgrade of your character motion:p. Also a downside might be the performance overhead of using P2 to mimic a skeleton, but you might be able to leave out some spritesheets and save some memory.

As an aside, why are your spritesheets 1000x1000, would it not be better to have POT textures?

A bit of promotion: The sprites you saw are from my own game and all the mechanics/motion of that character are based upon a LockConstraint :P

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...