mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-18 13:23:05 +00:00
add camera controller
This commit is contained in:
parent
939a7222ce
commit
69d11c805b
44
QSB/Instruments/QSBCamera/CameraController.cs
Normal file
44
QSB/Instruments/QSBCamera/CameraController.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.Instruments.QSBCamera
|
||||
{
|
||||
class CameraController : MonoBehaviour
|
||||
{
|
||||
private float _degreesX;
|
||||
private float _degreesY;
|
||||
private Quaternion _rotationX;
|
||||
private Quaternion _rotationY;
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
if (CameraManager.Instance.Mode != CameraMode.ThirdPerson)
|
||||
{
|
||||
return;
|
||||
}
|
||||
UpdateInput();
|
||||
UpdateRotation();
|
||||
}
|
||||
|
||||
private void UpdateInput()
|
||||
{
|
||||
var input = OWInput.GetValue(InputLibrary.look, false, InputMode.All);
|
||||
_degreesX += input.x * 180f * Time.fixedDeltaTime;
|
||||
_degreesY += input.y * 180f * Time.fixedDeltaTime;
|
||||
}
|
||||
|
||||
private void UpdateRotation()
|
||||
{
|
||||
_degreesX %= 360f;
|
||||
_degreesY %= 360f;
|
||||
_degreesY = Mathf.Clamp(_degreesY, -80f, 80f);
|
||||
_rotationX = Quaternion.AngleAxis(_degreesX, Vector3.up);
|
||||
_rotationY = Quaternion.AngleAxis(_degreesY, -Vector3.right);
|
||||
var localRotation = _rotationX * _rotationY * Quaternion.identity;
|
||||
gameObject.transform.parent.localRotation = localRotation;
|
||||
}
|
||||
}
|
||||
}
|
@ -59,6 +59,7 @@ namespace QSB.Instruments.QSBCamera
|
||||
Camera.enabled = false;
|
||||
OWCamera = CameraObj.AddComponent<OWCamera>();
|
||||
OWCamera.renderSkybox = true;
|
||||
CameraObj.AddComponent<CameraController>();
|
||||
|
||||
var screenGrab = CameraObj.AddComponent<FlashbackScreenGrabImageEffect>();
|
||||
screenGrab._downsampleShader = Locator.GetPlayerCamera().gameObject.GetComponent<FlashbackScreenGrabImageEffect>()._downsampleShader;
|
||||
|
@ -148,6 +148,7 @@
|
||||
<Compile Include="Events\EventNames.cs" />
|
||||
<Compile Include="DeathSync\PlayerDeathEvent.cs" />
|
||||
<Compile Include="Events\IQSBEvent.cs" />
|
||||
<Compile Include="Instruments\QSBCamera\CameraController.cs" />
|
||||
<Compile Include="Instruments\QSBCamera\CameraManager.cs" />
|
||||
<Compile Include="Instruments\QSBCamera\CameraMode.cs" />
|
||||
<Compile Include="Instruments\InstrumentsManager.cs" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user