예제 #1
0
        public void FixedUpdate()
        {
            Vector3 position = this.body1.position;

            if (this.lastPosition1 != Vector3.zero)
            {
                this.body1.velocity = (position - this.lastPosition1) / Time.fixedDeltaTime;
            }
            this.lastPosition1 = position;
            BoxCollider component = this.body1.GetComponent <BoxCollider>();
            BoxCollider collider2 = this.body2.GetComponent <BoxCollider>();

            DepenetrationForce.ApplyDepenetrationForce(this.body1, component, this.body2, collider2);
            DepenetrationForce.ApplyDepenetrationForce(this.body2, collider2, this.body1, component);
        }
예제 #2
0
        public void ApplyDepenetrationForce(FixedUpdateEvent evt, SelfPhysicNode selfPhysics, [JoinByBattle] ICollection <RemotePhysicNode> remotePhysics)
        {
            Rigidbody   rigidbody          = selfPhysics.rigidbody.Rigidbody;
            BoxCollider tankToTankCollider = (BoxCollider)selfPhysics.tankColliders.TankToTankCollider;
            bool        flag = false;

            foreach (RemotePhysicNode node in remotePhysics)
            {
                Rigidbody   rigidbody2 = node.rigidbody.Rigidbody;
                BoxCollider collider2  = (BoxCollider)node.tankColliders.TankToTankCollider;
                Bounds      bounds     = tankToTankCollider.bounds;
                if (bounds.Intersects(collider2.bounds))
                {
                    Entity entity = node.Entity;
                    if ((entity.HasComponent <TankActiveStateComponent>() || entity.HasComponent <TankDeadStateComponent>()) && DepenetrationForce.ApplyDepenetrationForce(rigidbody, tankToTankCollider, rigidbody2, collider2))
                    {
                        flag = true;
                    }
                }
            }
            rigidbody.maxDepenetrationVelocity = !flag ? MAX_DEPENETRATION_VELOCITY : 0f;
        }