コード例 #1
0
ファイル: PlayerController.cs プロジェクト: AMeghnad/AdvOOP
        void DetectClimbable()
        {
            // If we're already climbing, return
            if (isClimbing)
            {
                return;
            }
            // Otherwise, detect climbable
            // Perform a box cast that is the size of the player's collision
            Collider2D[] hits = Physics2D.OverlapBoxAll(transform.position, currentCollider.bounds.size, 0);
            // Loop through all hits
            foreach (var hit in hits)
            {
                // Check if:
                if (hit != null && // Something was hit
                    hit.isTrigger) // The hit object is a trigger
                {
                    // We have found our climbable!
                    climbObject = hit.GetComponent <Climbable>();
                    return;
                }

                // No climbable's were found
                climbObject = null;
            }
        }
コード例 #2
0
ファイル: PlayerController.cs プロジェクト: AMeghnad/AdvOOP
        void StopClimbing()
        {
            climbObject = null;

            // We are no longer climbing
            isClimbing = false;
            if (onClimbChanged != null)
            {
                onClimbChanged.Invoke(isClimbing);
            }
            // Re-enable physics
            EnablePhysics();
        }