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);
                    }
                }
            }
        }
Beispiel #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);
                    }
                }
            }
        }
 void LateUpdate()
 {
     if (player.OverlapCheck(floor))
     {
         Vector3 fix = player.FindFix(floor);
         player.GetComponent <PlayerMovement>().ApplyFix(fix);
     }
 }