我正在使用 GVRTeleport 脚本来允许使用纸板应用程序进行传送。我希望用于传送的光线投射忽略除一层之外的所有层。通过此页面,我相应地修改了脚本(抱歉,找不到此代码所有者的原始链接),但现在传送脚本什么也看不到。有任何想法吗?我的地板层是第 8 层,这是我希望此光线投射与之交互的层。
using UnityEngine;
public class GVRTeleport : MonoBehaviour {
public float viewHeight = 7f;
Vector3 fwd;
public float maxDistance = 10f;
public LineRenderer line;
public GameObject parent;
public GameObject targetIndicator;
public StraightLineParam genLine;
int layerMask = 1 << 8;
void Start() {
}
void Update() {
RaycastHit hit;
Ray ray;
if (Physics.Raycast (transform.position, Vector3.forward, Mathf.Infinity, layerMask)) {
Debug.Log ("The ray hit the floor");
if (debugWithMouse) {
Vector2 mousePos = new Vector2 (Input.mousePosition.x / Screen.width, …Run Code Online (Sandbox Code Playgroud)