JustPaste
HomeCategoriesAboutDonateContactTerms of UsePrivacy Policy
JustPaste

Free online notepad — write and share instantly

Navigate

  • Home
  • Timeline
  • Categories

Info

  • About
  • Donate
  • Contact

Legal

  • Terms of Use
  • Privacy Policy

© 2026 JustPaste.app. All rights reserved.

Made with ♥ by JustPaste

Untitled Page | JustPaste.app
about 2 months ago1 views
👨‍💻Programming
using UnityEngine;

public class BlockPlace : MonoBehaviour
{
    public GameObject blockPrefab;
    public Camera playerCamera;

    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = playerCamera.ScreenPointToRay(
                new Vector3(Screen.width / 2, Screen.height / 2));

            if (Physics.Raycast(ray, out RaycastHit hit, 5f))
            {
                Vector3 pos = hit.point + hit.normal * 0.5f;
                pos = new Vector3(
                    Mathf.Round(pos.x),
                    Mathf.Round(pos.y),
                    Mathf.Round(pos.z));

                Instantiate(blockPrefab, pos, Quaternion.identity);
            }
        }
    }
}
← Back to timeline