Author Topic: Colliders being quite strange  (Read 2410 times)

rain

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 79
    • View Profile
Colliders being quite strange
« on: April 25, 2012, 12:57:24 PM »
Hi!

I'm having a problem with colliders being positioned poorly.
My setup looks like this:

*UI Root(3D)
**Camera
***Anchor_Top
***Pause_Menu
****Label
****Quit
****Restart
****Resume
****SlicedSprite(Box)

The Quit,Restart and Resume gameObjects are "buttons", so they have box colliders on them.

The pause menu is normally hidden by having its objects' color alpha set to 0, plus the button game objects
 are rotated by 60 on the X angle.

When the player presses the pause buttons, the alpha values return to normal so they can be seen, and the button game objects get rotated back to (0,0,0) with a TweenRotation called by the pause button.

My problem is that the colliders seem to only be effective in a thin(approx. 15 pixels) line. Its like that the collider hasn't rotated back with the gameObjects, but the editor shows that it's all right.

In play mode, after I change the boxcolliders' positions manually, the colliders behave normally. This doesn't work if i change it in edit mode then hit play... the buttons only receive events in a line.
On the other hand, if I change the values via code, it doesn't seem to have any effect, regardless that it's runtime like when i change the values in play mode with the editor.

I really have no idea what to do, please help!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Colliders being quite strange
« Reply #1 on: April 25, 2012, 02:47:32 PM »
When adding colliders, make sure to use NGUITools.AddCollider to do that. Updating colliders -- same thing. Other than that, there is no reason why colliders wouldn't move with your game object, assuming you're moving the proper object. Collider is just another component of a game object.

rain

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 79
    • View Profile
Re: Colliders being quite strange
« Reply #2 on: April 26, 2012, 10:47:48 AM »
I looked up the nguitools script, but i don't understand how would i be able to position the collider properly after adding it. Could you explain it please? ;D

Edit:
I figured it out, thank you for your help :)
« Last Edit: April 26, 2012, 12:32:04 PM by rain »