Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Unity 3D example picking a target position on a terrain using the mouse cursor using ray casting
- using UnityEngine;
- using System.Collections;
- public class MouseTarget : MonoBehaviour {
- void Update ()
- {
- Ray ray = camera.ScreenPointToRay(Input.mousePosition);
- RaycastHit hit;
- if(Terrain.active.collider.Raycast(ray,out hit,Mathf.Infinity))
- {
- transform.position = hit.point
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement