Unity3d 用手指触摸代替第一人称角色
可能太容易了,但是。。。。。 这个脚本运行良好,从Boris Media获得。当角色进入框碰撞器时,它会显示文本,我不使用角色。我使用的是3D模型,因此用户必须触摸模型,而不是在游戏中行走。 提前谢谢Unity3d 用手指触摸代替第一人称角色,unity3d,unityscript,Unity3d,Unityscript,可能太容易了,但是。。。。。 这个脚本运行良好,从Boris Media获得。当角色进入框碰撞器时,它会显示文本,我不使用角色。我使用的是3D模型,因此用户必须触摸模型,而不是在游戏中行走。 提前谢谢 #pragma strict var note : GameObject; function Start () { note.SetActive (false); } function OnTriggerEnter () { note.SetActive (true); } functio
#pragma strict
var note : GameObject;
function Start () {
note.SetActive (false);
}
function OnTriggerEnter () {
note.SetActive (true);
}
function OnTriggerExit () {
note.SetActive (false);
}
下面是一个C语言示例,但如果需要,转换为JavaScript应该不会太难:
Vector2 touchPos = Input.GetTouch(0).position;
Ray ray = Camera.main.ScreenPointToRay(new Vector3(touchPos.x, touchPos.y, 0));
RaycastHit hit;
if (Physics.Raycast (ray, out hit)) {
// The user's touch has collided with something now we have to check what it collided with
// You can also use hit.point if you want to get the position of the touch in the world
if (hit.collider.tag == "GameObjectTag") {
Debug.Log("Hit " + hit.collider.name);
hit.collider.gameObject.setActive(true);
}
}
我对Unity和Script是新手,我花了很长时间才得到这个结果……我很高兴我能帮上忙: