|
1 | 1 | /* |
2 | 2 | * |
3 | 3 | * Author: Spencer Wilson |
4 | | - * Date: 3/14/2017 (Happy Pi-Day everyone!) |
| 4 | + * Date: 5/5/2017, 11:28 pm |
5 | 5 | * File: PlayerControl.cs |
6 | 6 | * Description: This file contains the code that takes user input in order to control the character. |
7 | 7 | * Disclaimer: A majority of this code I have gotten from tutorials. I have not been simply copying them, I have been |
@@ -62,10 +62,10 @@ private void Update() |
62 | 62 | void FixedUpdate() // Used a tutorial, hopefully going to be expanding on this method to suit the game's needs and functionalities. |
63 | 63 | { |
64 | 64 | PlayerRotation(); // Calls upon the PlayerRotation() function. |
65 | | - //PlayerRun(); // Calls upon the PlayerRun() function. |
| 65 | + PlayerRun(); // Calls upon the PlayerRun() function. |
66 | 66 | PlayerMovement(); // Calls upon the PlayerMovement() function. |
67 | 67 | //PlayerCrouch(); // Calls upon the PlayerCrouch() function. |
68 | | - //PlayerLean(); // Calls upon the PlayerLean() function. |
| 68 | + PlayerLean(); // Calls upon the PlayerLean() function. |
69 | 69 | //PlayerProne(); // Calls upon the PlayerProne() function. |
70 | 70 | PlayerPause(); |
71 | 71 | } |
@@ -192,27 +192,41 @@ void PlayerCrouch() |
192 | 192 |
|
193 | 193 |
|
194 | 194 |
|
195 | | - void PlayerLean() |
196 | | - { |
197 | | - if (Input.GetKeyDown("q")) |
198 | | - { |
199 | | - // Insert Lean Left Code Here |
200 | | - } |
201 | | - if (Input.GetKeyUp("q")) |
202 | | - { |
203 | | - // Insert Return To Normal Posture Code Here |
204 | | - } |
205 | | - if (Input.GetKeyDown("e")) |
206 | | - { |
207 | | - // Insert Lean Right Code Here |
208 | | - } |
209 | | - if (Input.GetKeyUp("e")) |
210 | | - { |
211 | | - // Insert Return To Normal Posture Code Here |
212 | | - } |
213 | | - } |
| 195 | + void PlayerLean() |
| 196 | + { |
| 197 | + float zRotation = 10f; // Holds value for rotation along the z-axis. |
| 198 | + float yRotation = 0; // Holds value for rotation along the y-axis. |
| 199 | + const float MAXZROTATION = (3f * Mathf.PI) / 2f; |
| 200 | + const float MINZROTATION = (Mathf.PI) / 4f; |
| 201 | + float newXRotation; |
| 202 | + |
| 203 | + if (Input.GetKeyDown("q")) |
| 204 | + { |
| 205 | + Debug.Log("Lean Left"); |
| 206 | + transform.localEulerAngles = new Vector3(0f, 0f, zRotation); |
| 207 | + // Mathf.Clamp(zRotation, MINZROTATION, MAXZROTATION); // Clamps rotation between two values to give a realistic range of leaning. |
| 208 | + } |
| 209 | + if (Input.GetKeyUp("q")) |
| 210 | + { |
| 211 | + Debug.Log("Upright position"); |
| 212 | + transform.localEulerAngles = new Vector3(0f, 0f, 0f); |
| 213 | + // Mathf.Clamp(zRotation, MINZROTATION, MAXZROTATION); // Clamps rotation between two values to give a realistic range of leaning. |
| 214 | + } |
| 215 | + if (Input.GetKeyDown("e")) |
| 216 | + { |
| 217 | + Debug.Log("Lean Right"); |
| 218 | + transform.localEulerAngles = new Vector3(0f, 0f, -zRotation); |
| 219 | + // Mathf.Clamp(zRotation, MINZROTATION, MAXZROTATION); // Clamps rotation between two values to give a realistic range of leaning. |
| 220 | + } |
| 221 | + if (Input.GetKeyUp("e")) |
| 222 | + { |
| 223 | + Debug.Log("Upright position"); |
| 224 | + transform.localEulerAngles = new Vector3(0f, 0f, 0f); |
| 225 | + // Mathf.Clamp(zRotation, MINZROTATION, MAXZROTATION); // Clamps rotation between two values to give a realistic range of leaning. |
| 226 | + } |
| 227 | + } |
214 | 228 |
|
215 | | - void PlayerProne() |
| 229 | + void PlayerProne() |
216 | 230 | { |
217 | 231 | // Insert Player Prone Stuff. Might have to call upon the PlayerMovement function here to change the value of speed so it is slower when crawling. |
218 | 232 | } |
|
0 commit comments