void LateUpdate()
        {
            PlayerMovement pm = player.GetComponent <PlayerMovement>();

            // prevents player from overlapping with platforms in list
            foreach (AABB box in platforms)
            {
                if (player.OverlapCheck(box))
                {
                    pm.ApplyFix(player.FindFix(box));
                }
            }

            foreach (AABB power in powerups)
            {
                if (player.OverlapCheck(power))
                {
                    // player collides with powerup
                    SpringBlock sb = power.GetComponent <SpringBlock>();
                    if (sb)
                    {
                        sb.PlayerHit(pm);
                    }
                }
            }
        }
示例#2
0
        // Checks collision between PLAYER and all PLATFORMS
        void LateUpdate()
        {
            if (!player)
            {
                return;          // if player dead, dont do collision detection
            }
            PlayerMovement pm = player.GetComponent <PlayerMovement>();

            // prevents player from overlapping with platforms in list
            foreach (AABB box in platforms)
            {
                if (player.OverlapCheck(box))
                {
                    pm.ApplyFix(player.FindFix(box));
                }
            }

            // Checks collision between PLAYER and all OVERLAP OBJECTS
            foreach (AABB power in powerups)
            {
                if (player.OverlapCheck(power))
                {
                    // player collides with powerup
                    OverlapObject oo = power.GetComponent <OverlapObject>();
                    if (oo)
                    {
                        oo.OnOverlap(pm);
                    }
                }
            }
        }
示例#3
0
 void LateUpdate()
 {
     if (player.OverlapCheck(floor))
     {
         Vector3 fix = player.FindFix(floor);
         player.GetComponent <PlayerMovement>().ApplyFix(fix);
     }
 }