My boxcollider gets offset when my character changes direction, is there any way to make the boxcollider change it’s offset through script? This is my code
if (velocityX < 0)
{
this.GetComponent<SpriteRenderer>().flipX = true;
this.GetComponent<BoxCollider2D>().offset.x = new Vector2(-0.2f, -0.6896644f);
}
But it comes back with an error, “Cannot modify return value because it is not a variable.”
Can anyone tell me what I’m doing wrong?
Thanks