I need help about GetComponent

I want to add 5 to size the of Box Collider, but when I type it, it gives an Error.

Ekran görüntüsü 2024-05-13 162740

How can I fix it ?

Hello @MREnis,

BoxCollider’s size is a Vector3, it’s a cube so it has 3 dimensions:

GetComponent<BoxCollider>().size = new Vector3(5, 5, 5);

You can also do

GetComponent<BoxCollider>().size = Vector3.one * 5;