I have a character with a weapon. It is a spine model.
I’ve been searching everywhere (that I can think of), have no idea of where to find a solution.
I believe that I first need to target the bone/sprite, and then hide or delete it.
In this case I will have an animation where the character loses/drops his weapon (out of screen) and the rest of the animations will simply continue without the weapon.
My guess is that it might cause issues removing a bone, because it is referenced in the spine json animation, so I figured that at least I should be able to hide it (set alpha to 0)
The game object bones are there so that you can attach other game objects to your spine model. Deleting or hiding them will not have any impact on the spine model itself.
What if the weapon is a separate game object with a sprite or spine model and you attach that to your character model (that now is without a weapon). When the character loses/drops the weapon you simply delete that game object.
I like the solution with attaching the gun as a gameobject, the you should be able to have a collision object as well to give the gun physics when it’s detached.
One more possible solution would be to have two Spine skins, one with the gun and one without. You can change skin in runtime with the “skin” property.
So my understanding is that I can’t in my case, target and delete (or set the alpha to zero) a single sprite that is attached to the model.
One issue I feel with the seprate gameobject is how it would follow with the other ones animation (since this character jumps, and moves all the time, even when in idle mode).
But the idea of 2 skins and switch on “weapon lost”-event appeals alot (even thought it will be slightly tedious since I have 30+ characters :D). So I’ll try that one out!
A spine model doesn’t consist of sprites. A spine component is a completely different kind of component from the sprite component.
You should give it a try at least. The separate game object, when attached to a bone in the hand will inherit the transform and thus rotate, scale and in other ways follow along with the bone.
Hello again, so I tried the idea with attaching a game object on another game object like this:
->game obj characters containing 2 figures
-> a separate game object containing single sprite (attachable item, in case a shell, instead of weapon).
in the main collection, I add the first go object, and also the second (shell) go.
So I have it (kind of) working, except I don’t understand the pivot point, because after some fiddeling I manage to have it the correct place, but as soon as some animations go off, the attached item seems to get way off…
(as if the pivot point was somewhere else).
So I guess the question is (assuming it’s just the pivot that’s wrong), where/how do I set that point?
And is the best practice to place it within the original go, or do I adjust the positioning in the collection (where both go are placed together).
I would recommend that you first try to attach a game object with a small circular sprite (not offset) to the spine bone. Is the bone where you expect it to be? If that its the case then next step would be to replace the tmp sprite with the actual sprite you wish to use. You can offset the sprite from the game object to control the pivot point.