Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by znSawyer · Jul 23, 2017 at 06:01 PM · destroycollidersevents

EventManager timing affecting desired GroupBounds output.

I am creating a box collider around a group of brown tiles with some padding. In one case, I am getting too much padding. Experimenting has led me to believe that the padding is due to white tiles that get destroyed moments before. These white tiles shouldn't be in the recalculated brown tile group collider. I have an Event Trigger that destroys all the white tiles before recalculating the bounds of the new grouped objects.

Even though the white tiles are destroyed, their colliders are still used in the recalculation. alt text alt text The console shows that the method containing the Destroy function was executed properly AND THEN the regroup was called.

I do not understand why Unity is creating the box collider of the white tiles, even though they have been destroyed.

Any help in understanding this issue would be helpful. Thanks in advanced.

//PlayedTileState.cs - class that is placed on a brownTileObject

    EventManager.TriggerEvent("DestroySelector");
 
    EventManager.pulledParam = int.Parse(gameObject.transform.root.name);
    EventManager.TriggerEvent("RemakeGroupCollider");

//SelectorTileController.cs - class that is placed on the white tiles

    private void DestroySelfWhenTilePlaced(int useless) {
         Object.Destroy(this.gameObject);
         Debug.Log("Destroyed selector tile on group#" + transform.root.name);
    }
  

//GroupManager.cs - This code is in a class that is placed on a GameManager Empty Object.

    private void makeGroupCollider(int groupNumber){
 
    BoxCollider groupCollider = groupList[groupNumber].AddComponent<BoxCollider>();
    Renderer[] groupColliders = groupList[groupNumber].GetComponentsInChildren<Renderer>();
    Bounds groupBounds = new Bounds(Vector3.zero, Vector3.zero);
 
    foreach(Renderer collider in groupColliders){
        if (groupBounds.extents == Vector3.zero)
            groupBounds = collider.bounds;
        groupBounds.Encapsulate(collider.bounds);
        groupCollider.center = groupBounds.center - groupList[groupNumber].transform.position;
        groupCollider.size = groupBounds.size;
        groupCollider.size = new Vector3(groupCollider.size.x + colliderSizeBuffer, 
           colliderYscale, groupCollider.size.z + colliderSizeBuffer);
        groupCollider.center = new Vector3(groupCollider.center.x, colliderYpos, 
           groupCollider.center.z + colliderZoffset);
        groupCollider.gameObject.layer = 8;
        }
    }
 
     private void RemakeGroupCollider(int groupNumber){
         Destroy(groupList[groupNumber].GetComponent<BoxCollider>());
         makeGroupCollider(groupNumber);
         Debug.Log("Remade Collider on Group#" + groupNumber);
     }
 
 


soa-unityanswer1-7-23.png (465.2 kB)
soa-unityanswer2-7-23.png (511.9 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by znSawyer · Jul 23, 2017 at 06:16 PM

I also tried Object.DestroyImmidiate(this.gameObject) and got:

 MissingReferenceException: The object of type 'SelectorTileController' has been destroyed but you  are still trying to access it.
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

112 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Get a collider's specific name / ID? 0 Answers

making objects react to colliders without tag C# 1 Answer

Can i find which script destroy my GO? 1 Answer

Which child collider is collided in main? 0 Answers

Will too many colliders affect game performance? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges