- Home /
Flipping a group of sprites
I have a character that is comprised of several gameobjects, each representing a body part with their own sprite renderer.(one object for left arm, one for left leg etc.)
I am aware that localscale.x *= -1.0f
flips the object but doing this creates weird behaviors when it comes to colliders. I also know about spriterenderer.flipX
but that doesn't flip the character around the correct pivot when it comes to multiple body parts.
tldr : How do i flip the entire character without changing the scale?
Wouldn't that affect the collision as well? Since the colliders themselves wouldn't rotate
Answer by gabrielgrames · Jul 02, 2019 at 03:52 PM
Hello!
Create a C# script and add this to the Update method+
side = Input.GetAxis("Horizontal");
if (side > 0)
{
GetComponent<SpriteRenderer>().flipX = false;
}
else if(side<0)
{
GetComponent<SpriteRenderer>().flipX = true;
}
Then, you add this script to each sprite you're using.
You can also create a method but its up to you.
You may need to change the order in layer by script, but it will depend on what you want. If you need help you can call me on discord: Risotto#4685. I hope I helped!