我对游戏中的脚本有一个快速的疑问,直到最近它一直运行良好。脚本工作是检测是否按下了正确的触发器并克隆游戏对象。脚本是
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Chisel : MonoBehaviour
{
private Transform chiselTransform;
private OVRGrabbable OVRGrabbable;
public OVRInput.Button button;
public Object cement;
// Start is called before the first frame update
void Start()
{
OVRGrabbable = GetComponent<OVRGrabbable>();
chiselTransform = GetComponent<Transform>();
}
// Update is called once per frame
void Update()
{
if (OVRGrabbable.isGrabbed && OVRInput.GetDown(button, OVRGrabbable.grabbedBy.GetController()))
{
//clone cement stuff TODO: add cement manager to delete unused cement
Instantiate(cement, chiselTransform.position, chiselTransform.rotation);
}
}
}
我不确定这是否有帮助,但是我在这里https://youtu.be/98gfkursxYI?t=470
使用了一些代码任何对此的帮助将是不错的。预先感谢!
答案 0 :(得分:0)
一个脚本显然丢失了。所以在我重新下载后,它是固定的
答案 1 :(得分:0)
public OVRInput.Controller GetController()
{
return m_controller;
}
必须添加到OVRGrabber.cs