- Home /
Box Collider z Axis unwanted reset
I have a simple plane (created with 2D Toolkit) and I'd like to limit the movement of that sprite in x direction. I have created a cube with a rigidbody and a box collider. I did the same for the sprite. However upon play the size and z-axis of the box collider automatically reverts to z:-100000 and size 0,0,0. How? Why? Where? Is this intended behaviour? There are no scripts that change these values.
Thanks.
Answer by glong · Nov 17, 2011 at 08:50 PM
I have the same problem. It seems to work fine when I use certain sprite collections, but the problem returns when I use the collection I need to use, or when I use a newly created sprite collection. I tried to remove and reload the tk2d sprite component, and the collider component disappeared entirely. This seems to be some sort of Tk2d bug. Let me know if you make any headway.
Answer by Nicolinux · Nov 18, 2011 at 03:13 AM
I worked around it by creating a cube with and added the sprite as a child to it. Then disabled the mesh renderer for the cube to make it inivisble. There I added a rigid body and restricted the movement. Since the sprite is attached to the cube, it follows the restricted movement. Another odd thing I noticed regarding this issue is that when I have two objects add a box collider, set "IsTrigger" and add a rigid body, then the objects do not collide but fall through each other.
Answer by glong · Nov 18, 2011 at 07:47 AM
Thanks. I will try some creative object parenting, though I still find it very frustrating that I can't have both a sprite and a collider on the same object, especially since I had it working before doing the latest TK2D update.
As for the "IsTrigger" issue, that is an intended behavior. That option is for when you want a collider to not be a physics collider, but instead be just a trigger for game events. Useful for making waypoints, powerups and such.
Answer by KeirMeikle · Dec 01, 2011 at 02:48 AM
In your sprite's collection, make sure Collider Type is set to "Unset"
Answer by dethmuffin · Oct 03, 2012 at 11:40 PM
Make sure that after you set the Collider type to "Unset", that you delete and re-add the box collider and rigid body to your sprite. That fixed it for me.