This might be a rather broad question, but I dont know what else to go on since I’m not sure if this is even possible in Unity. But it might be an easy thing since I’m a beginner
I have a 2D character which is made out of different body parts: Torso, legs, arms, head.
I’d like to make my character customizable that height and especially weight can be defined by a value form a script.
Here is an example:
Orange is representing the border of my 2D sprite in Unity.
Blue points should be fixed and not move
The distance between the two red points should be defined by a value.
I get what you’re trying to do here… for this to work there would have to be actual vertices as part of the sprite geometry, and you would need to access those and move them laterally appropriately.
Unfortunately Sprite / SpriteRenderer aren’t really set up for this sort of thing. With that API, as far as I know, what you need is not exposed.
HOWEVER… you could get this effect by producing your own piece of 2D geometry in a program like Blender3D, then subdividing it enough to give the animation flexibility you need above, and then rigging it with two bones to slide inwards.
This might cause other issues if other body parts are still done with sprites.
Another solution would be to use the above technique and a RenderTexture to “re-render” the basic sketch above once at runtime, re-“baking” it to a texture that now has the required dimensions, and making a fresh runtime Sprite out of that.
Honestly, I’d just create three (or five or ten) discrete variations, select between them and move on, perhaps revisit this in the future, as it will take quite a bit of 3D animation fiddling to make it look reasonable!
EDIT: There may be others here who can chime in with solutions such as Spline or Anima2D… I don’t have firsthand experience with those just now, but that might also be a path to take.
Hi, thank you very much for your reply and your ideas.
I kind of expected something like this. I’ll sure give it a try using Blender, that is a really good idea!
Using variations would have been my second option aswell, but since I have around 40 animations, it will multiply the work I have to put into creating the sprites.