Skip to content

Instantly share code, notes, and snippets.

@marcteys
Created September 22, 2015 22:25
Show Gist options
  • Save marcteys/3c542936a9e3f6601211 to your computer and use it in GitHub Desktop.
Save marcteys/3c542936a9e3f6601211 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class UnityClick : MonoBehaviour {
public LayerMask terrainLayer;
void Update()
{
if ( Input.GetMouseButtonDown(0))
{
RaycastHit hit ;
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast(ray, out hit, 100.0f, terrainLayer))
{
Debug.Log(hit.point);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment