Exemplo n.º 1
0
        private void UpdateCursorBlocks()
        {
            _isHit = WorldRaycaster.Raycast(_camera.position, _camera.forward);

            if (_isHit)
            {
                // ====== Update Place Block cursor ======

                var placeBlockPosition = WorldRaycaster.LastPosition;

                // don't show place block cursor if it collides with the player
                _collidesWithPlayer = PhysicsWorld.CheckBodyOnGlobalXyz(_playerBody, placeBlockPosition.x, placeBlockPosition.y, placeBlockPosition.z);

                _placeBlockCursor.Transform.position = placeBlockPosition;

                // ====== Update Mining cursor / position / time ======

                var hitPosition = WorldRaycaster.HitPosition;
                if (WorldRaycaster.HitPosition != _lastMinePosition)
                {
                    _mineBlockCursor.Transform.position = WorldRaycaster.HitPosition;

                    //position changed => reset mining timer
                    _miningStartedTime = Time.time;

                    _minedBlockType   = BlockDefs.GetDefinitionById((BlockTypeId)WorldModel.GetVoxel(hitPosition.x, hitPosition.y, hitPosition.z));
                    _lastMinePosition = hitPosition;
                }
            }

            UpdateCursorsVisibility();
        }