私は光源の内側から球にキャストしようとしています。 私の主なカメラの位置(0,0,0) 球の位置(0,0,0)半径:300 hit.positionとhit.collider.gameobjectを知りたい 私はチュートリアルの下でこれを試しています。 http://answers.unity3d.com/questions/129715/collision-detection-if-raycast-source-is-inside-a.htmlRaycastソースがColliderの中にある場合の衝突検出
チュートリアルを試みても、コンソールウィンドウからは望ましい結果が得られません。 (私のコンソールウィンドウにDebug.Logの結果はありません) どうすればいいですか?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EyeTrackingPoint : MonoBehaviour
{
public float sphereRadius = 300; // position(0,0,0) radius 300
public GameObject screen3D; // sphere
public void Update()
{
Camera cam = Camera.main; // position(0,0,0)
RaycastHit hit;
Ray ray = new Ray(cam.transform.position,cam.transform.rotation * Vector3.forward * sphereRadius);
ray.direction = -ray.direction;
if (Physics.Raycast(ray,out hit)&&hit.collider.gameObject.Equals(screen3D))
{
Debug.Log(hit.point);
}
}
}
ありがとうございます。