zHaytam

Hello,

I'm trying to create a UI system (health, mana, etc...) and I'm wondering if there is a way to have a circle with the character's head in it?

Maybe something in Spine can return to us a sprite that includes the character's head and then I can use it?
I'm asking here since the character can change/equip helmets so I need to show that in the circle too (like an rpg).

Thank you
zHaytam
  • Posts: 5

Harald

You can find an example scene called SpineGauge in Spine Examples/Other Examples that shows how to create a fully functional health bar via a spine skeleton. Instead of a flat bar you would then have a circular one, with an animated player's head in the center of your circle that could reflect the health status as well.

I would suggest however that you have the circle and the head as separate objects, then you can control and equip it more easily.
User avatar
Harald

Harri
  • Posts: 2075

zHaytam

The health bar is not the issue actually, I'm wondering if I can have the character's head in a circle somehow?
These are 2 separate things, the character's head is like an avatar and the health bar is next to it.

A "stupid" idea is to for example have a Camera that follows the character's head and renders it in a circle, but I need the avatar to always look right :/
Also this makes the avatar animated, I would be fine with the character's head alone (not animated).

Thank you!
zHaytam
  • Posts: 5

Harald

I'm not sure I understand your problem correctly, but what if you just create the head as a similar but separate Spine object as the character in the game part of the scene and equip it with the same items? Then you can animate it in-sync, or leave it in an idle animation or not animate it at all.
User avatar
Harald

Harri
  • Posts: 2075

zHaytam

That's a good idea actually!
What I want to do is display the character's head next to its health bar, just like in Fighting games.
For example:



But since the character can equip helmets, I want it to show that too (because I assume the avatar in these fighting games is just a static picture).
zHaytam
  • Posts: 5

Mario

You will have to render the character twice, once for the fight scene, and once for the head shot next to the healthbar. These need to become separate objects. To only render the head for the healthbar, you can define which slots to render in the rendering component IIRC. @Harald may have some more input regarding limiting what slots should be rendered.
User avatar
Mario

Mario
  • Posts: 2352

Harald

Thanks @badlogic for the input - good idea indeed! You could use the SkeletonRenderSeparator component to only draw a part of the model - in your case you would only want to render the head and everything attached to it for example. There is an example scene Spine Examples/Other Examples/SkeletonRenderSeparator that shows how to only draw the front of a character in one object, and only the back in a second one. In your case you would omit the second separated part of course (everything except for the head).

The only drawback is, that it is currently only supported for SkeletonAnimation objects.If you want to use it as a SkeletonGraphic, that's not yet supported but will be in the near future.
A ticket link can be found here: [unity] SkeletonRenderSeparator for SkeletonGraphic · #1254
User avatar
Harald

Harri
  • Posts: 2075


Return to Unity