This repository has been archived by the owner on Apr 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc88a9a
commit 71d7a6d
Showing
2 changed files
with
115 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
using System; | ||
using System.Collections; | ||
using Okomotive.FarLoneSails.SaveGame; | ||
using Okomotive.SideScrollerCharacterController; | ||
using Okomotive.Toolset; | ||
using UnityEngine; | ||
using UnityEngine.Rendering.PostProcessing; | ||
using UnityStandardAssets.ImageEffects; | ||
|
||
namespace Okomotive.FarLoneSails { | ||
public sealed partial class CameraEngine : MonoBehaviour { | ||
void Update() { | ||
if (Input.GetKeyDown(KeyCode.Numlock)) { | ||
this.noclip = !this.noclip; | ||
if (noclip) { | ||
// TODO: Save starting FOV | ||
} else { | ||
// TODO: Restore starting FOV | ||
} | ||
} | ||
|
||
if (noclip) { | ||
this.Noclip(); | ||
} | ||
} | ||
|
||
void FixedUpdate() { | ||
// (...) | ||
if (this.noclip) { | ||
return; | ||
} | ||
// (...) | ||
} | ||
|
||
void Noclip() { | ||
// FOV | ||
if (Input.GetAxis("Mouse ScrollWheel") < 0f) { | ||
this.camera.fov -= this.fovChange; | ||
} | ||
if (Input.GetAxis("Mouse ScrollWheel") > 0f) { | ||
this.camera.fov += this.fovChange; | ||
} | ||
Mathf.Clamp(this.camera.fov, 0f, 300f); | ||
|
||
// Camera Rotation | ||
this.cameraXAngle += 0.5f * Input.GetAxis("Mouse X"); | ||
this.cameraYAngle -= 0.5f * Input.GetAxis("Mouse Y"); | ||
Mathf.Clamp(this.cameraYAngle, -50f, 50f); | ||
this.camera.transform.eulerAngles = new Vector3(this.cameraYAngle, this.cameraXAngle, 0f); | ||
|
||
// Position | ||
float speedModifier = 1f; | ||
if (Input.GetKey(KeyCode.Keypad0)) { // boost | ||
speedModifier = 8f; | ||
} | ||
if (Input.GetKey(KeyCode.Home)) { // forwards | ||
Vector3 direction = camera.transform.forward; | ||
direction.Normalize(); | ||
camera.transform.position += Time.deltaTime * speedModifier * noclipSpeed * direction; | ||
} | ||
if (Input.GetKey(KeyCode.End)) { // backwards | ||
Vector3 direction = camera.transform.forward; | ||
direction.Normalize(); | ||
camera.transform.position -= Time.deltaTime * speedModifier * noclipSpeed * direction; | ||
} | ||
if (Input.GetKey(KeyCode.Delete)) { // left | ||
Vector3 direction = camera.transform.right; | ||
direction.Normalize(); | ||
camera.transform.position -= Time.deltaTime * speedModifier * noclipSpeed * direction; | ||
} | ||
if (Input.GetKey(KeyCode.PageDown)) { // right | ||
Vector3 direction = camera.transform.right; | ||
direction.Normalize(); | ||
camera.transform.position += Time.deltaTime * speedModifier * noclipSpeed * direction; | ||
} | ||
if (Input.GetKey(KeyCode.Insert)) { // down | ||
Vector3 direction = camera.transform.up; | ||
direction.Normalize(); | ||
camera.transform.position -= Time.deltaTime * speedModifier * noclipSpeed * direction; | ||
} | ||
if (Input.GetKey(KeyCode.PageUp)) { // up | ||
Vector3 direction = camera.transform.up; | ||
direction.Normalize(); | ||
camera.transform.position += Time.deltaTime * speedModifier * noclipSpeed * direction; | ||
} | ||
} | ||
|
||
void SaveStartPos() {} | ||
|
||
void RestoreSavedPos() {} | ||
|
||
Camera camera; | ||
|
||
// (...) | ||
|
||
bool noclip = true; | ||
float fovChange = 500f * Time.deltaTime; | ||
float noclipSpeed = 50f; | ||
} | ||
} |