Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions akil
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using UnityEngine;

public class BlockPlacer : MonoBehaviour
{
public GameObject blockPrefab; // এখানে আপনার তৈরি করা কিউবটি ড্র্যাগ করে দিন

void Update()
{
// মাউসের বাম বাটনে ক্লিক করলে ব্লক বসবে
if (Input.GetMouseButtonDown(0))
{
PlaceBlock();
}
}

void PlaceBlock()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;

if (Physics.Raycast(ray, out hit))
{
// যেখানে ক্লিক করা হয়েছে ঠিক সেই পজিশনে নতুন ব্লক তৈরি হবে
Vector3 spawnPos = hit.point + hit.normal * 0.5f;

// গ্রিড সিস্টেমের জন্য পজিশন রাউন্ড করা (মাইনক্রাফটের মতো)
spawnPos.x = Mathf.Round(spawnPos.x);
spawnPos.y = Mathf.Round(spawnPos.y);
spawnPos.z = Mathf.Round(spawnPos.z);

Instantiate(blockPrefab, spawnPos, Quaternion.identity);
}
}
}