Hello Guest

Author Topic: Rendering Bug? - Negative ScaleX + Rotation  (Read 6899 times)

Babaganoosh

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Rendering Bug? - Negative ScaleX + Rotation
« on: December 28, 2013, 02:10:33 am »
Hey Dinesh,

I'm having a strange issue with nested sprites with negative ScaleX rotating weirdly. It's hard to describe, basically I'm making a badminton game and I have a Racket which consists of a blank game object container and 2 children: a racket sprite and a hitbox, both tk2dSlicedSprite's. I'm using HOTween to rotate the Racket to swing and when the Player (parent of the Racket) ScaleX = 1 everything works correctly. For the opposing player I just set ScaleX to -1, but when the racket rotates for some reason the racket rotates clockwise  and the hitbox rotates counter-clockwise..

SS #1 shows what the racket looks like before rotation.

SS #2 shows how it looks while swinging (hitbox rotates correctly, but the racket sprite rotates clockwise).

SS #3, I toggle the enable box in the inspector and now it's rendered correctly.

When I rotate the racket in the inspector, it rotates normally. Not sure if it's a HOTween issue, I don't understand what's causing this at all. Only difference between the hitbox and racket sprite is a collider/kinematic rigid body, I tried disabling in "Play Mode" and no change. I've read that Unity3d has issues with negative scale + colliders, is there another way I can flip a whole GameObject with nested tk2dSprite's without using negative Scale X or Y Rotation?

Babaganoosh

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Rendering Bug? - Negative ScaleX + Rotation
« Reply #1 on: December 28, 2013, 07:10:16 am »
I figured out a dumb workaround, disabling and re-enabling the GameObject on every frame. It would be great to find out what was causing it though.

I don't know if it's related but I think I found a unity bug, colliders apparently don't rotate properly when scale X is negative. I'm getting the feeling negative scale isn't well supported with Unity.
« Last Edit: December 28, 2013, 07:19:22 am by Babaganoosh »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Rendering Bug? - Negative ScaleX + Rotation
« Reply #2 on: December 28, 2013, 07:44:24 pm »
I'm not sure about your exact issue (don't have enough info to go off), but with the object rotating the wrong way, isn't that because you're flipping the parent? When you do that a CW rotation will become CCW?

Babaganoosh

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Rendering Bug? - Negative ScaleX + Rotation
« Reply #3 on: December 28, 2013, 08:58:08 pm »
Yeah it's suppose to be CCW. One of them rotates CW and one rotates CCW, both children on the same level, doesn't make any sense.