Skip to content

Commit c5579dd

Browse files
committed
Documentation; Removed unused code.
1 parent ac6f799 commit c5579dd

21 files changed

Lines changed: 579 additions & 242 deletions
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=assets_005Cplugins/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

Assets/Plugins/UnityTutorialSystem/Scenes/Scripts/CharacterBehaviour.cs

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,55 @@
1-
using UnityEngine;
1+
using NaughtyAttributes;
2+
using UnityEngine;
23
using UnityEngine.Events;
34

4-
namespace TutorialSystem.Scenes.Scripts
5+
namespace UnityTutorialSystem.Scenes.Scripts
56
{
7+
/// <summary>
8+
/// A basic character controller that allows WASD movement and mouse look in a single script.
9+
/// </summary>
610
[RequireComponent(typeof(CharacterController))]
711
public class CharacterBehaviour : MonoBehaviour
812
{
13+
[BoxGroup("Movement")]
14+
[Tooltip("Modifier Key to enable strafing movement")]
915
[SerializeField] KeyCode strafeKey;
16+
17+
[BoxGroup("Movement")]
18+
[Tooltip("Alternative modifier Key to enable strafing movement")]
1019
[SerializeField] KeyCode strafeKey2;
20+
21+
[BoxGroup("Movement")]
22+
[SerializeField] bool independentHeadMovement;
23+
24+
[BoxGroup("Movement")]
25+
[SerializeField] bool invertHeadLook;
26+
[BoxGroup("Movement")]
27+
[SerializeField] bool mouseMovement;
28+
29+
[BoxGroup("Movement Speed")]
1130
[SerializeField] float forwardMovementSpeed;
31+
[BoxGroup("Movement Speed")]
1232
[SerializeField] float reverseMovementSpeed;
33+
[BoxGroup("Movement Speed")]
1334
[SerializeField] float strafeSpeed;
14-
[SerializeField] float movementThreshold;
35+
[BoxGroup("Movement Speed")]
1536
[SerializeField] float rotationSpeed;
16-
[SerializeField] bool independentHeadMovement;
17-
[SerializeField] bool invertHeadLook;
37+
[BoxGroup("Movement Speed")]
38+
[Tooltip("At which velocity does the animation system show an movement animation?")]
39+
[SerializeField] float movementThreshold;
40+
41+
[BoxGroup("Internal")]
1842
[SerializeField] Transform head;
19-
[SerializeField] bool mouseMovement;
43+
2044
CharacterController characterController;
21-
public UnityEvent MovementBlocked;
22-
public UnityEvent Moving;
45+
[SerializeField] UnityEvent movementBlocked;
46+
[SerializeField] UnityEvent moving;
2347

24-
public CollisionFlags MovementResult { get; set; }
48+
public UnityEvent MovementBlocked => movementBlocked;
49+
50+
public UnityEvent Moving => moving;
51+
52+
public CollisionFlags MovementResult { get; private set; }
2553

2654
void Reset()
2755
{
@@ -39,14 +67,6 @@ void Awake()
3967
characterController = GetComponent<CharacterController>();
4068
}
4169

42-
void OnEnable()
43-
{
44-
}
45-
46-
void OnDisable()
47-
{
48-
}
49-
5070
void FixedUpdate()
5171
{
5272
var h = Input.GetAxis("Horizontal");
@@ -77,23 +97,23 @@ void FixedUpdate()
7797

7898
if (mouseMovement)
7999
{
80-
HandleMouseLook();
100+
head.localRotation = HandleMouseLook();
81101
}
82102

83103
MovementResult = characterController.Move(velocity);
84104

85105
if (MovementResult != 0)
86106
{
87-
MovementBlocked?.Invoke();
107+
movementBlocked?.Invoke();
88108
}
89109

90110
if (characterController.velocity.magnitude > movementThreshold)
91111
{
92-
Moving?.Invoke();
112+
moving?.Invoke();
93113
}
94114
}
95115

96-
void HandleMouseLook()
116+
Quaternion HandleMouseLook()
97117
{
98118
var mouseLookAxisX = independentHeadMovement ? Input.GetAxis("Mouse X") : 0;
99119
var mouseLookAxisY = Input.GetAxis("Mouse Y") * (invertHeadLook ? 1 : -1);
@@ -103,8 +123,8 @@ void HandleMouseLook()
103123
var eulers = head.localRotation.eulerAngles;
104124
eulers.y += angleY;
105125
eulers.x = Mathf.Clamp(Mathf.DeltaAngle(0, eulers.x + angleX), -45, 45);
106-
107-
head.localRotation = Quaternion.Euler(eulers.x, eulers.y, 0);
126+
eulers.z = 0;
127+
return Quaternion.Euler(eulers);
108128
}
109129
}
110130
}

Assets/Plugins/UnityTutorialSystem/Scenes/TutorialAssembly.unity

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)