Hello everyone. I’m making 2d platformer for android. So I need help. When I play animation with that guy in picture, I resize his collider by setting size of sprites collider to size of sprite. Its box collider by the way. So what i get is huge collider that starts from his back and ends in tip of the spear. I think its pretty stupid that if you step on collider, that gives damage ,with your spear, you get damage. So if anyone could tell me how to make his collider start from his back and end with his hands, I’d be really greatful. Thanks in advance.
P.s. I really need that collider resize to still be a thing. Because I want to be able to change sprites and it’s sizes at run time, so collider resize is required.
Okay. I solved it myself.
It can helpful if you post the solution that you arrived at for future readers who might have the same or similar issue as you ![]()
Glad you solved it, too. ![]()
here I found what I was searching for. Center part of boxcollider2d is now obsolete, so just edit your sprites pivot point.
Also you can use offset . Heres my part of that code:
if(classOfChoice ==1){
Vector2 _size = spriteRenderer.size;
boxColl2D.size = new Vector2 (_size.x / 3f, _size.y);
boxColl2D.offset = new Vector2 (-0.1f, 0.5f);
}
So with this code I resize collider according to class I chose… You can play with values near to _size.x and _size.y, also with offset, to match your needs.
