Esempio n. 1
0
 protected void OnTriggerEnter2D(Collider2D other)
 {
     if (FromTriggers && QualifyAccess(other))
     {
         Colliders.Add(other);
         OnColliderEnter?.Invoke(other);
     }
 }
Esempio n. 2
0
        protected void OnCollisionEnter2D(Collision2D collision)
        {
            var other = collision.collider;

            if (FromCollisions && QualifyAccess(other))
            {
                Colliders.Add(other);
                OnColliderEnter?.Invoke(other);
            }
        }
        /// <summary>
        /// 碰撞逻辑检测
        /// 调用相应的碰撞方法
        /// </summary>
        public void OnCollision(UserData collision)
        {
            isColliderMethodEnter = true;

            if (isColliderStay == false)
            {
                OnColliderEnter?.Invoke(collision);
                isColliderStay = true;
            }
            if (isColliderStay)
            {
                OnColliderStay?.Invoke(collision);
            }
        }
        private void ProcessEvents(bool colliding)
        {
            if (colliding)
            {
                triggerCollider = closestHit.collider;
            }

            if (colliding && wasColliding)             // Stay
            {
                OnColliderStay?.Invoke(triggerCollider);
            }
            else if (colliding && !wasColliding)             // Enter
            {
                OnColliderEnter?.Invoke(triggerCollider);
            }
            else if (!colliding && wasColliding)             // Leave
            {
                OnColliderLeave?.Invoke(triggerCollider);
            }

            wasColliding = colliding;
        }
 public void OnContactEnter(UserData data)
 {
     OnColliderEnter?.Invoke(data);
     contactActors.Add(data);
     isContactEnterFlag = true;
 }