Beispiel #1
0
        void LateUpdate()
        {
            if (!player)
            {
                return;          // no player, don't do collision detection
            }
            PlayerMovement pm = player.GetComponent <PlayerMovement>();

            // checking collision between PLAYER and all PLATFORMS:
            foreach (AABB box in platforms)
            {
                if (player.OverlapCheck(box))
                {
                    Vector3 fix = player.FindFix(box);
                    pm.ApplyFix(player.FindFix(box));
                }
            }

            // checking collision between PLAYER and all OVERLAP OBJECTS
            foreach (AABB power in powerups)
            {
                if (player.OverlapCheck(power))
                {
                    //player collides with powerup!
                    // do something...

                    OverlapObject oo = power.GetComponent <OverlapObject>();

                    if (oo)
                    {
                        oo.OnOverlap(pm);
                    }
                }
            }
        }
Beispiel #2
0
        void LateUpdate()
        {
            PlayerMovement pm = player.GetComponent <PlayerMovement>();

            foreach (AABB box in platforms)
            {
                if (player.OverlapCheck(box))
                {
                    Vector3 fix = player.FindFix(box);
                    pm.ApplyFix(player.FindFix(box));
                }
            }

            foreach (AABB power in powerups)
            {
                if (player.OverlapCheck(power))
                {
                    //player collides with powerup!
                    // do something...
                    SpringBlock sb = power.GetComponent <SpringBlock>();
                    if (sb)
                    {
                        sb.PlayerHit(pm);
                    }
                }
            }
        }
        void LateUpdate()
        {
            if (player.OverlapCheck(floor))
            {
                Vector3 fix = player.FindFix(floor);

                player.GetComponent <PlayerMovement>().ApplyFix(fix);
            }
        }