Exemplo n.º 1
0
    static void Activate()
    {
        if (!active)
        {
            active = true;

            List <Rigidbody> filter = new List <Rigidbody>();

            Rigidbody[] arrayOfAllRB = Object.FindObjectsOfType <Rigidbody>();

            foreach (Rigidbody rb in arrayOfAllRB)
            {
                //first make sure it' a sim object
                if (rb.GetComponentInParent <SimObjPhysics>())
                {
                    //ok now make sure that the sim object is moveable or pickupable
                    SimObjPhysics sop = rb.GetComponentInParent <SimObjPhysics>();

                    if (sop.PrimaryProperty == SimObjPrimaryProperty.Moveable || sop.PrimaryProperty == SimObjPrimaryProperty.CanPickup)
                    {
                        if (!rb.GetComponent <DecalCollision>())
                        {
                            //don't add object if it's in an object specific receptacle-so things like towels and toilet paper that are mounted by default
                            if (sop.transform.parent.name != "AttachPoint")
                            {
                                filter.Add(rb);
                            }
                        }
                    }

                    IgnoreCollision[] ignoreCollisionObjects = sop.GetComponentsInChildren <IgnoreCollision>();
                    foreach (IgnoreCollision ic in ignoreCollisionObjects)
                    {
                        ic.SetupIgnoreCollision();
                    }
                }
            }

            // Normally avoid Find functions, but this is editor time and only happens once
            workList = filter.ToArray();//Object.FindObjectsOfType<Rigidbody>();

            // we will need to ensure autoSimulation is off to manually tick physics
            cachedAutoSimulation = Physics.autoSimulation;
            activeTime           = 0f;

            // make sure that all rigidbodies are awake so they will actively settle against changed geometry.
            foreach (Rigidbody body in workList)
            {
                body.isKinematic = false;
                body.WakeUp();
            }
        }
    }
Exemplo n.º 2
0
        public void DisableObjectCollisionWithAgent(string objectId)
        {
            var physicsSceneManager = FindObjectOfType <PhysicsSceneManager>();

            if (!physicsSceneManager.ObjectIdToSimObjPhysics.ContainsKey(objectId))
            {
                return;
            }

            SimObjPhysics target = physicsSceneManager.ObjectIdToSimObjPhysics[objectId];

            disableCollistionWithPickupObject = true;
            foreach (Collider c0 in this.GetComponentsInChildren <Collider>())
            {
                foreach (Collider c1 in target.GetComponentsInChildren <Collider>())
                {
                    Physics.IgnoreCollision(c0, c1);
                }
            }
        }