- Home /
Flip object using transform.localScale in C#
Hi!
As simple as the title says, I just want to flip my character using transfrom.localScale. But I I just keep getting errors. Any idea how I could do it?
Answer by RiQQ · Jun 29, 2014 at 04:03 PM
So far i have worked with it, you have to set the whole scale again by giving it new Vector3 value
ie.
// flip the x scale
transform.localScale = new Vector3(transform.localScale.x *-1, transform.localScale.y, transform.localScale.z);
well yes if you put it straight to Update() it will, but you can always add bitflag to check it.
ie.
private bool flipped = false;
if(transform.localScale.x < 0 && !flipped)
{
// flip character code
}
Answer by no00ob · Jan 13, 2018 at 03:29 PM
How would I flip a character thats 3d and its in 2d enviroment? I tried the code you supplied with *-1 in the z too but it just doesnt flip it fully... any fixes?
Edit: nvm found a fix just didnt change the x at all only z, fixed it for me at least.
Your answer
Follow this Question
Related Questions
Object scale/rotation changes when parented to flipped object 0 Answers
Flipping. (transform.Rotate VS transform.localScale) 0 Answers
flip enemy 1 Answer
Flipping ( localscale/rotate unfitting ) 0 Answers