Exemple #1
0
        public void applyBlink(float elapsedTime, Player player, Vector3 move)
        {
            BoundingBox playerBoundingBox = player.getBoundingBox();
            Vector3     cent = center(playerBoundingBox);

            //fix the move with a hitscan
            HitScan hs = hitscan(cent, Vector3.Normalize(move), null);

            if (hs != null && hs.Distance() < Math.Sqrt(Vector3.Dot(move, move)))
            {
                move = Vector3.Normalize(move) * hs.Distance() + hs.collisionFace.plane.getNormal() * 70;
            }

            Vector3 offset       = center(playerBoundingBox) - player.getPosition();
            Vector3 playerRadius = size(playerBoundingBox) * 0.5f;
            Vector3 basePoint    = toESpace(playerRadius, cent);
            Vector3 evelocity    = toESpace(playerRadius, move);
            Vector3 pos          = collideWithWorld(playerRadius, basePoint, evelocity, 0, player);

            player.setPosition(toWorldSpace(playerRadius, pos) - offset);
        }
        public void applyBlink(float elapsedTime, Player player, Vector3 move)
        {
            BoundingBox playerBoundingBox = player.getBoundingBox();
            Vector3 cent = center(playerBoundingBox);

            //fix the move with a hitscan
            HitScan hs = hitscan(cent, Vector3.Normalize(move), null);
            if (hs != null && hs.Distance() < Math.Sqrt(Vector3.Dot(move, move)))
                move = Vector3.Normalize(move) * hs.Distance() + hs.collisionFace.plane.getNormal()*70;

            Vector3 offset = center(playerBoundingBox) - player.getPosition();
            Vector3 playerRadius = size(playerBoundingBox) * 0.5f;
            Vector3 basePoint = toESpace(playerRadius, cent);
            Vector3 evelocity = toESpace(playerRadius, move);
            Vector3 pos = collideWithWorld(playerRadius, basePoint, evelocity, 0, player);

            player.setPosition(toWorldSpace(playerRadius, pos) - offset);
        }