I have an animated sprite that is enemy When I apply collider of any kind it moves with the enemy but when the enemy attacks it changes its size but collider does not change its size as per sprite.
There are 7 to 8 images in the animation. Can I change the size of the collider with each animation image of the sprite in the Animator?
I would use primitive collider too. Maybe a capsule collider. The size from the primitive collider can be controlled trough the animation. Ok, it will not exactly pass into the sprite still in most case this isn’t needed.
maybe create 7 childobjects with different colliders and enable them depended on animation ?
In 2D I thought the primitive colliders were box colliders or circle colliders? I did not think one could optimally compound the capsule colliders. In 3D development I believe you can use them.
there is capsule 2d collider, still I have looked at it and its direction can’t be saved in the animation (vertical-horizontal). Also I think box collider 2d will be better.
Take one box collider 2d. Go into the animation window, select the frame where the colliders size should be changed, enable record button and change the colliders size.
Yes, there are capsule collider 2D but I thought that only the box and circle colliders were considered “primitive” colliders. In 3D I believe, if I’m not mistaking, that even a capsule collider is considered a primitive collider. I’m not so certain that the capsule colliders will adjust properly according to movement in 2D. However, I am in agreement with you about the box colliders. I think this would be the most efficient way for him to go.
To answer his question about “How can I do this”?
You can create an empty object and put a Physics2D box collider on it and attach it to the part you want. Then duplicate and keep putting the colliders where you want. Maybe you don’t need them to be active until certain times during an animation. The code to access colliders is relatively simple so enabling/disabling them wouldn’t require much coding.