I have a script the sets it’s child’s scale to a negative so the sprite on it inverts when an empty that follows the cursor moves to the other side of the script’s object. Here is the code:
switch (transform.InverseTransformPoint(follower.position).x)
{
case < 0:
sprite.localScale = new Vector3(-5, sprite.localScale.y, 0);
break;
case > 0:
sprite.localScale = new Vector3(5, sprite.localScale.y, 0);
break;
}
I also have other sprites as children of the one getting flipped that show the other parts of the character’s body, and these other sprites frequently need to go over their parent. The problem is this code seems to force all the children of the object it flips to be on the same Z level as it, despite the fact it doesn’t touch anyone’s position, leaving all the numbers the same. I know it’s this code because commenting it out fixes the problem. I’ve tried setting the Z back to what it should be, but that doesn’t work since the number isn’t being changed in the first place. I can’t just get rid of it, so what do i do here?