| 1234567891011121314151617181920212223242526 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CrossHair : MonoBehaviour
- {
- // Start is called before the first frame update
- public Camera bowCamera;
- public static CrossHair ins;
- void Start()
- {
- ins = this;
- }
- public Vector3 getRayHitPoint() {
- RaycastHit hit;
- Ray ray = bowCamera.ScreenPointToRay(this.transform.position, Camera.MonoOrStereoscopicEye.Mono);
- bool raycastResult = Physics.Raycast(ray.origin, ray.direction, out hit, 60, 1 << 8);
- if (raycastResult) {
- return hit.point;
- } else {
- return bowCamera.transform.position + bowCamera.transform.forward * 60;
- }
- }
- }
|