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.

59 lines
1.2 KiB

3 years ago
using System;
using UnityEngine;
namespace UnityStandardAssets.Utility
{
public class CameraRefocus
{
public Camera Camera;
public Vector3 Lookatpoint;
public Transform Parent;
private Vector3 m_OrigCameraPos;
private bool m_Refocus;
public CameraRefocus(Camera camera, Transform parent, Vector3 origCameraPos)
{
m_OrigCameraPos = origCameraPos;
Camera = camera;
Parent = parent;
}
public void ChangeCamera(Camera camera)
{
Camera = camera;
}
public void ChangeParent(Transform parent)
{
Parent = parent;
}
public void GetFocusPoint()
{
RaycastHit hitInfo;
if (Physics.Raycast(Parent.transform.position + m_OrigCameraPos, Parent.transform.forward, out hitInfo,
100f))
{
Lookatpoint = hitInfo.point;
m_Refocus = true;
return;
}
m_Refocus = false;
}
public void SetFocusPoint()
{
if (m_Refocus)
{
Camera.transform.LookAt(Lookatpoint);
}
}
}
}