Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class Raycast : MonoBehaviour
- {
- private Camera cam;
- private void Start()
- {
- cam = this.GetComponent<Camera>();
- }
- private void Update()
- {
- Ray ray = cam.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
- Vector3 forward = this.transform.TransformDirection(Vector3.forward) * 100;
- RaycastHit hit;
- if (Physics.Raycast(ray, out hit))
- {
- if (hit.transform.tag == "Object")
- {
- hit.transform.GetComponent<ObjectGlow>().highlighted = true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement