Hey.
Im making a terraria like game. I have never used raycasts before and went ahead and tried to write a script for when the player is hitting a block. Here it is:
using UnityEngine;
using System.Collections;
public class HitRay : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButton(0))
{
Vector3 ray = Input.mousePosition;
if (Physics.Raycast(transform.position, ray, 5))
{
print("Hit something");
}
}
}
}
How would i get something like this to work?