- Home /
Question by
guigaCA · Mar 20, 2015 at 03:35 PM ·
2dboundscollider 2d
BoxCollider2D().bounds.extents.Set() isn't working
I'm trying to make an item list and in order to do that I want the items to have a specific boxcollider size so I can know which one was clicked. The problem is, when I try to use "BoxCollider2D>().bounds.extents.Set()" it does not change it. For instance if a try this:
Debug.Log(tempItem.GetComponent<BoxCollider2D>().bounds.ToString());
tempItem.GetComponent<BoxCollider2D>().bounds.extents.Set(10f,10f,0);
Debug.Log(tempItem.GetComponent<BoxCollider2D>().bounds.ToString());
tempItem.GetComponent<BoxCollider2D>().bounds.extents.Set(20f,20f,0);
Debug.Log(tempItem.GetComponent<BoxCollider2D>().bounds.ToString());
All cases are giving the same output, which in my case is "extents = (1.5f,1.5f,0)
Am I doing it wrong, or is it really a bug?
PS: I know I could change the transform.localScale to change the collider, but I want the sprite to keep the size it has now.
Thanks in advance!
Comment