Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.61 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class Raycast : MonoBehaviour
  4. {
  5.     private Camera cam;
  6.  
  7.     private void Start()
  8.     {
  9.         cam = this.GetComponent<Camera>();
  10.     }
  11.  
  12.     private void Update()
  13.     {
  14.         Ray ray = cam.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
  15.  
  16.         Vector3 forward = this.transform.TransformDirection(Vector3.forward) * 100;
  17.  
  18.         RaycastHit hit;
  19.         if (Physics.Raycast(ray, out hit))
  20.         {
  21.             if (hit.transform.tag == "Object")
  22.             {
  23.                 hit.transform.GetComponent<ObjectGlow>().highlighted = true;
  24.             }
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement