Exemple #1
0
        void Update()
        {
            Vector3 movementDirection = new Vector3(Input.GetAxis("Horizontal"), 0f, Input.GetAxis("Vertical"));
            bool    jump   = Input.GetButton("Jump");
            bool    crouch = Input.GetButton("Crouch");

            _characterMovement.Move(movementDirection, jump, crouch);

            RaycastHit hit;

            if (Physics.Raycast(_camera.transform.position, _camera.transform.forward, out hit, 10f))
            {
                if (Input.GetButtonDown("Fire1"))
                {
                    BreakBlock(hit.point + (-0.1f * hit.normal));
                }
                if (Input.GetButtonDown("Fire2"))
                {
                    PlaceBlock(hit.point + (0.1f * hit.normal));
                }

                TooltipUI.SetActive(true);
                int  id   = Chunk.GetWorldId(hit.point + (-0.1f * hit.normal));
                Item item = ItemDatabase.GetItemById(id);
                if (item != null)
                {
                    TooltipUI.text.text = "" + item.name;
                }
            }
            else
            {
                TooltipUI.SetActive(false);
            }
        }