Is doing this using code possible?
when i was looking through the Unity Script Reference for BoxColliders there didn’t seem to be a function for it. So i thought what if i delete the current boxcollider then generate a new one? wouldnt that technically serve a “reset”?
Now i was able to delete the collider but the code didnt generate a new one. i wonder is it because the Destroy operation is delayed so having the script the way i had it would mean i destroyed the box collider i generated too? Here’s what i have in the script.
if(gameObject.GetComponent<BoxCollider>().enabled)
Destroy(gameObject.collider);
gameObject.AddComponent("BoxCollider");
gameObject.GetComponent<BoxCollider>().isTrigger = true;
what does resetting a box collider do? (what are you trying to do?)
– Loiusresetting a box collider would automatically set the box collider to my gameobject. i have a gameobject for monsters thats being generated/spawned and by changing the monsterID in code i can change that monster to any other monster of my choice. so now for collision detection i want to put a boxcollider around the monster but since its the same object and all the monster sizes are different it would be a pain to write the code of the sizes individually. by resetting the boxcollider i wont have to
– GrandMasterHsu