2D rotation weird behavior. please help

i’m a newbie and making a 2D game when you can drag things around and rotate it with touches, but i got a little problem on rotation.

here is my bus before rotation(it’s using Image, so it has rect transform component):
2290958--154095--Screen Shot 2015-09-11 at 5.15.57 PM.png

when i rotate using script or inspector(by changing the rotation value on Z), it goes like this:
2290958--154096--Screen Shot 2015-09-11 at 5.16.27 PM.png
as you notice, the bound gets bigger as the object rotates.

but, when i rotate the object using the rotation tools on upper left, it goes like this:
2290958--154097--Screen Shot 2015-09-11 at 5.16.51 PM.png
the bound rotates with the object, this is what i want to achieve via script, instead the bound getting bigger.

why is that? both ways above change the same Z rotation value on rect transform component.
how can i rotate both the object and its bound via script as shown in last screenshot?

thanks

i’m using Unity 5

The boundaries you are seeing in that last image (the rotation you are trying to achieve through script) is not possible. That box is meant to be an AABB (axis-aligned bounding-box) which means it can’t have diagonal lines to make up the box. If you deselect and reselect the object, I’m sure you’ll see the box looks like the box from your second image, and that is correct.

This doesn’t have to be your collision box. If you add a boxCollider component to that bus, you’ll be able to rotate that exactly how you want. I recommend BoxCollider2D for 2D games.

1 Like

@MSplitz-PsychoK ooh i see, thank you for the reply :slight_smile: