Skip to content
This repository has been archived by the owner on Apr 30, 2023. It is now read-only.

Commit

Permalink
Add CameraEngine.cs modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
abarichello committed May 19, 2019
1 parent fc88a9a commit 71d7a6d
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 3 deletions.
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ This mod restores the developer's original debug mode and provides camera moveme
<!-- ## Video -->
<!-- Click any screenshot below to watch a video demo. -->
<div>
<a href="http://yt.barichello.me"><img src="https://i.imgur.com/MOS5CuW.png" width="400"></a>
<a href="http://yt.barichello.me"><img src="https://i.imgur.com/pBfHQym.png" width="400"></a>
<a href="http://yt.barichello.me"><img src="https://i.imgur.com/MOS5CuW.png" width="800"></a>
<a href="http://yt.barichello.me"><img src="https://i.imgur.com/pBfHQym.png" width="800"></a>
</div>

## Usage

#### Debug mode
Hotkey|Action
-|-
'(Quote)|Toggle debug mode
F1|Refill energy
F4|Update weather
F5|Toggle level helpers
Expand All @@ -25,3 +26,14 @@ Shift+J|Force damage front wheel
Shift+K|Force vehicle break apart event
Shift+C|Force credits roll
Shift+I|Force reset vehicle

#### Noclip
Hotkey|Action
-|-
Numlock|Toggle noclip mode
Scroll wheel up|Increase FOV
Scroll wheel down|Reduce FOV
Home/End|Forwards/Backwards
Del/Page Down|Left/Right
Insert/Page Up|Dowm/Up
Keypad0|Hold for increased camera speed
100 changes: 100 additions & 0 deletions src/CameraEngine.cs
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;
}
}

0 comments on commit 71d7a6d

Please sign in to comment.