Move Collider2D programatically

well, someone made this question in 2013 and it has no answer. I couldn’t find yet something to point me if is there a way to do this but what I’ve tryed until now was: = 0.1


collider2D.bounds.size.x = 0.1

however it has no effect on my scene…so could someone explain to me if I’m doing something wrong or if there is a way to move my Collider2D?


I don’t think there is a generic way to move a Collider2D. You are going to have to do a GetComponent on the specific type of Collider2D you have on the object, and then manipulate that collider based on the properties exposed. For example if you have a box or circle collider, you can just set its center, but for a polygon collider, you would have to change the local space coordiantes of the polygon.