VR模拟枪支打靶,消灭鬼怪,换弹以及上弦等等硬核枪支操作。 使用HTCVive设备,开启SteamVR进行游玩。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

44 lines
815 B

using UnityEngine;
using System.Collections;
public class GunAim:MonoBehaviour
{
public int borderLeft;
public int borderRight;
public int borderTop;
public int borderBottom;
private Camera parentCamera;
private bool isOutOfBounds;
void Start ()
{
parentCamera = GetComponentInParent<Camera>();
}
void Update()
{
float mouseX = Input.mousePosition.x;
float mouseY = Input.mousePosition.y;
if (mouseX <= borderLeft || mouseX >= Screen.width - borderRight || mouseY <= borderBottom || mouseY >= Screen.height - borderTop)
{
isOutOfBounds = true;
}
else
{
isOutOfBounds = false;
}
if (!isOutOfBounds)
{
transform.LookAt(parentCamera.ScreenToWorldPoint (new Vector3(mouseX, mouseY, 5.0f)));
}
}
public bool GetIsOutOfBounds()
{
return isOutOfBounds;
}
}