- Home /
Question by
ronin sixshooter · Apr 17, 2011 at 06:01 AM ·
mirrorfliplocalscale
Using transform.localScale to flip object
I am using this line of code to flip the object around when it walks left or right (Im making a 2D game)
transform.localScale = Vector3(transform.localScale.x, transform.localScale.y, transform.localScale.z * -1);
The problem I am running into is that saying:
transform.Translate((Vector3.forward moveSpeed) Time.deltaTime);
always has the character moving to the right. This happens even if I flipped the object around. I thought that flipping the object would also flip its forward pointing direction. Am I doing something wrong?
Comment
Answer by DaveA · Apr 17, 2011 at 07:01 AM
No, as you've seen, the scale only affects the appearance. You would have to do something similar with the 'walk' code, the direction of movement vector.