Question by
gamer_bros_64 · Sep 11, 2020 at 10:38 AM ·
minecraft
how do i make a player mine blocks?
the current script i have is this placeing scrit `using UnityEngine; using System.Collections;
public class PlaceBlock2 : MonoBehaviour
{
public float range = 5;
public Transform prefab;
RaycastHit hit;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width * 0.5f, Screen.height * 0.5f, 0f));
if (Physics.Raycast(ray, out hit, range))
{
// Pointing Ray
Debug.DrawLine(transform.position, hit.point, Color.red);
// Point to place
Vector3 V = new Vector3(Mathf.Round(hit.point.x), Mathf.Round(hit.point.y + 0.5f), Mathf.Round(hit.point.z));
// Place Ray
Debug.DrawLine(transform.position, V, Color.blue);
// Place Block
if (Input.GetMouseButtonDown(0))
{
Instantiate(prefab, V, Quaternion.identity);
}
bool XPositive = hit.point.y > hit.transform.position.y ? true : false;
bool XNegative = hit.point.x > hit.transform.position.x ? true : false;
}
}
}
but i still cant mine blocks i nead a script that can -mine blocks touched by the curser
-is simple and can be added to my place block sript
-and is good.
Comment
Your answer
Follow this Question
Related Questions
How to hide faces of a mesh that I dont see? 1 Answer
Instantiate too many objects 0 Answers
Perlinnoise, blocks load far apart 0 Answers
How to fix the blocks placement? 1 Answer
How do you make a json animation file into an animation in unity? 1 Answer