Question by
haxorbird · Nov 19, 2020 at 03:43 PM ·
animationunity 2dspritessprite renderer
How to make a customizable player's animations?
Hi, I have made a customizable player. It is a 2d game platformer game. The player is customized by changing the sprites of Cap, eyes etc. everything works fine when the player is still. But when the player is animated, base of the player moves but attached items such as cap and eye do not move. I can't find any solution to this. One thing I tried is to change the localPosition of attached items when the animation frame changes.
if (currentFrame == 1)
{
Cap.transform.localPosition = new Vector3(0.03f, 0.5f, 0f);
}
else if (currentFrame == 2)
{
Cap.transform.localPosition = new Vector3(0.03f, 0.5f, 0f);
}
else if (currentFrame == 3)
{
Cap.transform.localPosition = new Vector3(0.058f, 0.5f, 0f);
}
else if (currentFrame == 5)
{
Cap.transform.localPosition = new Vector3(0.025f, 0.5f, 0f);
}
else
{
Cap.transform.localPosition = new Vector3(0f, 0.5f, 0f);
}
But this will be very difficult to do when there are many possibilities. I have to find where the cap should be in every frame of the animation. Can anyone help me with what I am trying to do?
Comment