Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 0.45 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. [ExecuteInEditMode]
  5. public class NPC_Node : MonoBehaviour {
  6.         void Update() {
  7.             Camera.main.transform.LookAt(Camera.main.ScreenToWorldPoint(Input.mousePosition));
  8.                 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  9.                 RaycastHit hit;
  10.                 Debug.DrawRay(ray.origin, ray.direction * 1000, Color.yellow);
  11.                 if (Physics.Raycast(ray, out hit, 1000.0f)) {
  12.                         Debug.Log("Hit " + collider.gameObject.name);
  13.                 }
  14.         }
  15. }