PopeSpaceous / Solitary

A 2D Puzzle Platformer built with Unity
Other
6 stars 10 forks source link

Flip Parallelogram does not work properly at certain angles #139

Open jespirit opened 5 years ago

jespirit commented 5 years ago

Flipping the parallelogram when it is rotated on the z-axis at 45, 135, 225, or 315 degrees does not work properly.

parallelogram-yaxis-rotate

Expected:

parallelogram-yaxis-rotate-expected

parallelogram-rotate-expected

I have a fix but I need to do more testing. I'm not sure if it may or may not break solving a tangram puzzle.

//used for flip button
public void Flip(){
    //rotate 180 on y axis
    transform.Rotate (new Vector3 (0, 180, 0));
    //when its flipped the direction is off by 1 unit for some reason, so we add one.
    direction = (int)((this.transform.eulerAngles.z+1.0f) / 45);
    //toggle flip variable
    flipped = (flipped)?false:true;
}

Replace transform.Rotate (new Vector3 (0, 180, 0)); with the following that will flip the parallelogram horizontally without any rotations.

Vector3 flippedScale = transform.localScale;
flippedScale.x *= -1;
transform.localScale = flippedScale;
PopeSpaceous commented 5 years ago

Good catch. The Issue is all yours if you want it.