Esempio n. 1
0
 protected void OnTriggerExit2D(Collider2D other)
 {
     if (Colliders.Contains(other))
     {
         Colliders.Remove(other);
         OnColliderExit?.Invoke(other);
     }
 }
Esempio n. 2
0
        protected void OnCollisionExit2D(Collision2D collision)
        {
            var other = collision.collider;

            if (Colliders.Contains(other))
            {
                Colliders.Remove(other);
                OnColliderExit?.Invoke(other);
            }
        }
        public void Update()
        {
            //老版 物理碰撞
            if (isColliderStay == true && isColliderMethodEnter == false)
            {
                isColliderStay = false;
                OnColliderExit?.Invoke(null);
            }

            //Log.Trace("物理碰撞 持续数量" + contactActors.Count);
            //新版物理碰撞
            if (contactActors.Count > 0)
            {
                foreach (var i in contactActors)
                {
                    //持续伤害
                    OnColliderStay?.Invoke(i);
                    //Log.Trace("物理碰撞 持续" + i);
                }
            }
            //附上值
            angleVelocity_copy    = m_body.AngularVelocity;
            LinearVelocity_copy   = m_body.LinearVelocity;
            Torque_copy           = m_body.GetTorque();
            Damping_copy          = m_body.LinearDamping;
            isColliderMethodEnter = false;
            //Force_copy = m_body.GetForce();
            //if(Force_copy.LengthSquared() > 1000000)
            //{
            //    Force_copy.Normalize();
            //    Force_copy = Force_copy * 31.62277660168379f;
            //}

            Force_copy_copy = Force_copy;

            m_body.AddForce(Force_copy);


            //Log.Trace("已经添加力量:" + m_body.GetForce()+" "+Force_copy);
            //Log.Trace("Update Mass" + m_body.Mass);
            Force_copy = Vector2.Zero;

            TickFlag();
        }
 public void OnContactExit(UserData data)
 {
     OnColliderExit?.Invoke(data);
     contactActors.Remove(data);
     isContactExitFlag = true;
 }