I am making a small game to learn Unity.
In the game, the character can slide. He has a EdgeCollider2D normally. When he slides, I would like the EdgeCollider2D to shrink to fit the character model as he is sliding.
I am currently trying to do this as shown below:
public void ChangeColliderForSlide()
{
//used in animator behavior script
edge2d.points.SetValue(new Vector2(-0.35f, -0.15f), 0);
edge2d.points.SetValue(new Vector2(-0.35f, -0.55f), 1);
edge2d.points.SetValue(new Vector2(0.4f, -0.55f), 2);
edge2d.points.SetValue(new Vector2(0.4f, -0.15f), 3);
edge2d.points.SetValue(new Vector2(-0.35f, -0.15f), 4);
}
This would shrink the collider and should be called as the player enter the slide animation, however, as I pause the game and check, the character's collider was not changed at all, and has the original values.
Would appreciate anyone who has an idea of what might be the problem here.
Thanks.