Question by
whatisthislol · Sep 07, 2020 at 08:40 AM ·
sizeboxcollider2dactive
gameObject.activeInHierarchy not working
I have a set of GameObjects that disables if one is enabled and I also want to disable the BoxCollider of the gameObject. the GetComponent<BoxCollider2D>().enable
is not working so now Im just trying to change the size of the collider so it wont be detected in the game. here is my code
void Start()
{
col = platform1.GetComponent<BoxCollider2D>();
}
// Update is called once per frame
void Update()
{
if (platform1.activeInHierarchy == true)
{
col.size =new Vector3(7.6f, 6.25f, 0);
}
else
{
col.size = new Vector3(0, 0, 0);
}
}
this script is attached to the gameObject itself.
Comment
Answer by xxmariofer · Sep 07, 2020 at 01:07 PM
simply change to
platform1.activeSelf
also enable should be working so probably your error is somewhere else
thank you! was able to make it work by editing the whole script haha
Your answer
Follow this Question
Related Questions
Getting Child Box Collider2D Size 0 Answers
Changing the size of a ball, problems with transform.localScale 1 Answer
Build Size 0 Answers
Exclude dlls from build 1 Answer