浏览代码

Merge branch 'DeivSky/state-machine' into main

Conflicts are all regarding the renaming of the namespace from Deivsky to UOP1

# Conflicts:
#	UOP1_Project/Assets/Scripts/StateMachine/Core/IStateComponent.cs
#	UOP1_Project/Assets/Scripts/StateMachine/Core/State.cs
#	UOP1_Project/Assets/Scripts/StateMachine/Core/StateAction.cs
#	UOP1_Project/Assets/Scripts/StateMachine/Core/StateCondition.cs
#	UOP1_Project/Assets/Scripts/StateMachine/Core/StateMachine.cs
#	UOP1_Project/Assets/Scripts/StateMachine/Core/StateTransition.cs
#	UOP1_Project/Assets/Scripts/StateMachine/ScriptableObjects/StateActionSO.cs
#	UOP1_Project/Assets/Scripts/StateMachine/ScriptableObjects/StateConditionSO.cs
#	UOP1_Project/Assets/Scripts/StateMachine/ScriptableObjects/StateSO.cs
#	UOP1_Project/Assets/Scripts/StateMachine/ScriptableObjects/StateTransitionSO.cs
/main
Ciro Continisio 4 年前
当前提交
c9bcfaeb
共有 120 个文件被更改,包括 1333 次插入200 次删除
  1. 67
      UOP1_Project/Assets/Prefabs/Pig.prefab
  2. 15
      UOP1_Project/Assets/Scenes/CharController.unity
  3. 158
      UOP1_Project/Assets/Scripts/Characters/Character.cs
  4. 39
      UOP1_Project/Assets/Scripts/Characters/Protagonist.cs
  5. 2
      UOP1_Project/Assets/Scripts/StateMachine/Core/IStateComponent.cs
  6. 2
      UOP1_Project/Assets/Scripts/StateMachine/Core/State.cs
  7. 2
      UOP1_Project/Assets/Scripts/StateMachine/Core/StateAction.cs
  8. 2
      UOP1_Project/Assets/Scripts/StateMachine/Core/StateCondition.cs
  9. 2
      UOP1_Project/Assets/Scripts/StateMachine/Core/StateMachine.cs
  10. 2
      UOP1_Project/Assets/Scripts/StateMachine/Core/StateTransition.cs
  11. 2
      UOP1_Project/Assets/Scripts/StateMachine/ScriptableObjects/StateActionSO.cs
  12. 2
      UOP1_Project/Assets/Scripts/StateMachine/ScriptableObjects/StateConditionSO.cs
  13. 2
      UOP1_Project/Assets/Scripts/StateMachine/ScriptableObjects/StateSO.cs
  14. 2
      UOP1_Project/Assets/Scripts/StateMachine/ScriptableObjects/StateTransitionSO.cs
  15. 194
      UOP1_Project/ProjectSettings/InputManager.asset
  16. 4
      .gitignore
  17. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist.meta
  18. 8
      UOP1_Project/Assets/Scripts/Characters/StateMachine.meta
  19. 13
      UOP1_Project/Assets/Scripts/StateMachine/UOP1.StateMachine.asmdef
  20. 7
      UOP1_Project/Assets/Scripts/StateMachine/UOP1.StateMachine.asmdef.meta
  21. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions.meta
  22. 14
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/ApplyMovementVector.asset
  23. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/ApplyMovementVector.asset.meta
  24. 14
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/Ascend.asset
  25. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/Ascend.asset.meta
  26. 14
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/Descend.asset
  27. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/Descend.asset.meta
  28. 15
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/GroundGravity.asset
  29. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/GroundGravity.asset.meta
  30. 15
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/MoveInTheAir.asset
  31. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/MoveInTheAir.asset.meta
  32. 15
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/Rotate.asset
  33. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/Rotate.asset.meta
  34. 15
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/RotateFast.asset
  35. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/RotateFast.asset.meta
  36. 15
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/Slide.asset
  37. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/Slide.asset.meta
  38. 15
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/SlidingGravity.asset
  39. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/SlidingGravity.asset.meta
  40. 15
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/Walk.asset
  41. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/Walk.asset.meta
  42. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions.meta
  43. 14
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/HasHitHead.asset
  44. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/HasHitHead.asset.meta
  45. 14
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/IsGrounded.asset
  46. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/IsGrounded.asset.meta
  47. 14
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/IsHoldingJump.asset
  48. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/IsHoldingJump.asset.meta
  49. 15
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/IsMoving.asset
  50. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/IsMoving.asset.meta
  51. 14
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/IsSliding.asset
  52. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/IsSliding.asset.meta
  53. 15
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/JumpHoldTimer.asset
  54. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/JumpHoldTimer.asset.meta
  55. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/States.meta
  56. 20
      UOP1_Project/Assets/ScriptableObjects/Protagonist/States/Idle.asset
  57. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/States/Idle.asset.meta
  58. 22
      UOP1_Project/Assets/ScriptableObjects/Protagonist/States/JumpAscending.asset
  59. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/States/JumpAscending.asset.meta
  60. 22
      UOP1_Project/Assets/ScriptableObjects/Protagonist/States/JumpDescending.asset
  61. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/States/JumpDescending.asset.meta
  62. 21
      UOP1_Project/Assets/ScriptableObjects/Protagonist/States/Sliding.asset
  63. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/States/Sliding.asset.meta
  64. 24
      UOP1_Project/Assets/ScriptableObjects/Protagonist/States/Walking.asset
  65. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/States/Walking.asset.meta
  66. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions.meta
  67. 19
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/BeginJump.asset
  68. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/BeginJump.asset.meta
  69. 22
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/BeginJumpDescent.asset
  70. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/BeginJumpDescent.asset.meta
  71. 19
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/HitHead.asset
  72. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/HitHead.asset.meta
  73. 22
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/LandIdle.asset
  74. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/LandIdle.asset.meta
  75. 22
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/LandWalking.asset
  76. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/LandWalking.asset.meta
  77. 19
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/StartSliding.asset
  78. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/StartSliding.asset.meta
  79. 19
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/StartWalking.asset
  80. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/StartWalking.asset.meta
  81. 19
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/StopSliding.asset
  82. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/StopSliding.asset.meta
  83. 19
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/StopWalking.asset
  84. 8
      UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/StopWalking.asset.meta
  85. 8
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions.meta
  86. 24
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/ApplyMovementVectorActionSO.cs
  87. 11
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/ApplyMovementVectorActionSO.cs.meta
  88. 50
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/AscendActionSO.cs
  89. 11
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/AscendActionSO.cs.meta
  90. 45
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/DescendActionSO.cs
  91. 11
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/DescendActionSO.cs.meta
  92. 35
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/GroundGravityActionSO.cs
  93. 11
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/GroundGravityActionSO.cs.meta

67
UOP1_Project/Assets/Prefabs/Pig.prefab


serializedVersion: 6
m_Component:
- component: {fileID: 3341179906418240731}
- component: {fileID: 3341179907149091245}
- component: {fileID: 3341179906418240708}
- component: {fileID: 3341179906418240708}
- component: {fileID: 3341179907149091245}
- component: {fileID: 1044138830}
m_Layer: 0
m_Name: Pig
m_TagString: Untagged

m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &211818859182309264
--- !u!143 &3341179907149091245
CharacterController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3341179906418240709}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Height: 1.75
m_Radius: 0.4
m_SlopeLimit: 45
m_StepOffset: 0.3
m_SkinWidth: 0.08
m_MinMoveDistance: 0.001
m_Center: {x: 0, y: 0.875, z: 0}
--- !u!114 &3341179906418240708
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}

m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 45f6466be0a32e746abeb31b2a794001, type: 3}
m_Script: {fileID: 11500000, guid: 4eb0e4f8f5e39624ea81504bf968dcce, type: 3}
inputReader: {fileID: 11400000, guid: 945ec0365077176418488737deed54be, type: 2}
gameplayCamera: {fileID: 0}
--- !u!114 &3341179906418240708
jumpInput: 0
movementInput: {x: 0, y: 0, z: 0}
movementVector: {x: 0, y: 0, z: 0}
--- !u!114 &211818859182309264
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}

m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4eb0e4f8f5e39624ea81504bf968dcce, type: 3}
m_Script: {fileID: 11500000, guid: 45f6466be0a32e746abeb31b2a794001, type: 3}
speed: 8
turnSmoothTime: 0.2
gravityMultiplier: 5
initialJumpForce: 10
jumpInputDuration: 0.4
gravityComebackMultiplier: 15
maxFallSpeed: 50
gravityDivider: 0.6
--- !u!143 &3341179907149091245
CharacterController:
_inputReader: {fileID: 11400000, guid: 945ec0365077176418488737deed54be, type: 2}
gameplayCamera: {fileID: 0}
--- !u!114 &1044138830
MonoBehaviour:
m_Material: {fileID: 0}
m_IsTrigger: 0
serializedVersion: 2
m_Height: 1.75
m_Radius: 0.4
m_SlopeLimit: 30
m_StepOffset: 0.3
m_SkinWidth: 0.08
m_MinMoveDistance: 0.001
m_Center: {x: 0, y: 0.875, z: 0}
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1eeda163c70b3cb4ebb88ba92f608fd8, type: 3}
m_Name:
m_EditorClassIdentifier:
CurrentState:
debug: 0
_initialStateSO: {fileID: 11400000, guid: e128814ff6dbf63449bbc4dc8b6dc066, type: 2}
--- !u!1 &3791421269865525050
GameObject:
m_ObjectHideFlags: 0

15
UOP1_Project/Assets/Scenes/CharController.unity


propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2125786286893897154, guid: e978d53d440e0814086759404585ac32,
type: 3}
propertyPath: m_LocalPosition.x
value: -3.5
objectReference: {fileID: 0}
- target: {fileID: 2125786286893897154, guid: e978d53d440e0814086759404585ac32,
type: 3}
propertyPath: m_LocalPosition.z
value: -14
objectReference: {fileID: 0}
- target: {fileID: 2125786286893897154, guid: e978d53d440e0814086759404585ac32,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e978d53d440e0814086759404585ac32, type: 3}
--- !u!1001 &2370768318719443585

158
UOP1_Project/Assets/Scripts/Characters/Character.cs


using UnityEngine;
using UnityEngine.PlayerLoop;
/// <summary>
/// <para>This class is a data holder that the <c>StateMachine</c> class uses to deposit data that needs to be shared between states.
/// Ideally, both the player character and NPCs can use this component to drive locomotion.</para>
/// <para>Also used to listen to the native Unity Message <c>OnControllerColliderHit</c> from the <c>CharacterController</c> component,
/// which requires a <c>MonoBehaviour</c> to be listened to.</para>
/// </summary>
private CharacterController characterController;
[Tooltip("Horizontal XZ plane speed multiplier")] public float speed = 8f;
[Tooltip("Smoothing for rotating the character to their movement direction")] public float turnSmoothTime = 0.2f;
[Tooltip("General multiplier for gravity (affects jump and freefall)")] public float gravityMultiplier = 5f;
[Tooltip("The initial upwards push when pressing jump. This is injected into verticalMovement, and gradually cancelled by gravity")] public float initialJumpForce = 10f;
[Tooltip("How long can the player hold the jump button")] public float jumpInputDuration = .4f;
[Tooltip("Represents how fast gravityContributionMultiplier will go back to 1f. The higher, the faster")] public float gravityComebackMultiplier = 15f;
[Tooltip("The maximum speed reached when falling (in units/frame)")] public float maxFallSpeed = 50f;
[Tooltip("Each frame while jumping, gravity will be multiplied by this amount in an attempt to 'cancel it' (= jump higher)")] public float gravityDivider = .6f;
[Tooltip("Adjust the friction of the slope")] public float slideFriction = 0.3f;
[Tooltip("Starting vertical movement when falling from a platform")] public float fallingVerticalMovement = -5f;
private float gravityContributionMultiplier = 0f; //The factor which determines how much gravity is affecting verticalMovement
private bool isJumping = false; //If true, a jump is in effect and the player is holding the jump button
private float jumpBeginTime = -Mathf.Infinity; //Time of the last jump
private float turnSmoothSpeed; //Used by Mathf.SmoothDampAngle to smoothly rotate the character to their movement direction
private float verticalMovement = 0f; //Represents how much a player will move vertically in a frame. Affected by gravity * gravityContributionMultiplier
private float currentSlope;
private Vector3 hitNormal; // ground normal
private bool shouldSlide; // Should player slide?
private Vector3 inputVector; //Initial input horizontal movement (y == 0f)
private Vector3 movementVector; //Final movement vector
private const float ROTATION_TRESHOLD = .02f; // Used to prevent NaN result causing rotation in a non direction
private void Awake()
{
characterController = GetComponent<CharacterController>();
}
private void Update()
{
//Raises the multiplier to how much gravity will affect vertical movement when in mid-air
//This is 0f at the beginning of a jump and will raise to maximum 1f
if (!characterController.isGrounded)
{
gravityContributionMultiplier += Time.deltaTime * gravityComebackMultiplier;
}
//Reduce the influence of the gravity while holding the Jump button
if (isJumping)
{
//The player can only hold the Jump button for so long
if (Time.time >= jumpBeginTime + jumpInputDuration)
{
isJumping = false;
gravityContributionMultiplier = 1f; //Gravity influence is reset to full effect
}
else
{
gravityContributionMultiplier *= gravityDivider; //Reduce the gravity effect
}
}
//Calculate the final verticalMovement
if (!characterController.isGrounded)
{
//Less control in mid-air, conserving momentum from previous frame
movementVector = inputVector * speed;
//The character is either jumping or in freefall, so gravity will add up
gravityContributionMultiplier = Mathf.Clamp01(gravityContributionMultiplier);
verticalMovement += Physics.gravity.y * gravityMultiplier * Time.deltaTime * gravityContributionMultiplier; //Add gravity contribution
//Note that even if it's added, the above value is negative due to Physics.gravity.y
//Cap the maximum so the player doesn't reach incredible speeds when freefalling from high positions
verticalMovement = Mathf.Clamp(verticalMovement, -maxFallSpeed, 100f);
}
else
{
//Full speed ground movement
movementVector = inputVector * speed;
//Resets the verticalMovement while on the ground,
//so that regardless of whether the player landed from a high fall or not,
//if they drop off a platform they will always start with the same verticalMovement.
//-5f is a good value to make it so the player also sticks to uneven terrain/bumps without floating
if (!isJumping)
{
verticalMovement = fallingVerticalMovement;
gravityContributionMultiplier = 0f;
}
}
UpdateSlide();
//Apply the result and move the character in space
movementVector.y = verticalMovement;
characterController.Move(movementVector * Time.deltaTime);
//Rotate to the movement direction
movementVector.y = 0f;
if (movementVector.sqrMagnitude >= ROTATION_TRESHOLD)
{
float targetRotation = Mathf.Atan2(movementVector.x, movementVector.z) * Mathf.Rad2Deg;
transform.eulerAngles = Vector3.up * Mathf.SmoothDampAngle(
transform.eulerAngles.y,
targetRotation,
ref turnSmoothSpeed,
turnSmoothTime);
}
}
//These fields are manipulated by the StateMachine actions
[HideInInspector] public bool jumpInput;
[HideInInspector] public Vector3 movementInput; //Initial input coming from the Protagonist script
[HideInInspector] public Vector3 movementVector; //Final movement vector, manipulated by the StateMachine actions
[HideInInspector] public ControllerColliderHit lastHit;
hitNormal = hit.normal;
bool isMovingUpwards = verticalMovement > 0f;
if (isMovingUpwards)
{
// Making sure the collision is near the top of the head
float permittedDistance = characterController.radius / 2f;
float topPositionY = transform.position.y + characterController.height;
float distance = Mathf.Abs(hit.point.y - topPositionY);
if (distance <= permittedDistance)
{
// Stopping any upwards movement
// and having the player fall back down
isJumping = false;
gravityContributionMultiplier = 1f;
verticalMovement = 0f;
}
}
lastHit = hit;
inputVector = movement;
movementInput = movement;
// Disable jumping if player has to slide
if (characterController.isGrounded && !shouldSlide)
{
isJumping = true;
jumpBeginTime = Time.time;
verticalMovement = initialJumpForce; //This is the only place where verticalMovement is set to a positive value
gravityContributionMultiplier = 0f;
}
jumpInput = true;
isJumping = false; //This will stop the reduction to the gravity, which will then quickly pull down the character
}
private void UpdateSlide()
{
// if player has to slide then add sideways speed to make it go down
if (shouldSlide)
{
movementVector.x += (1f - hitNormal.y) * hitNormal.x * (speed - slideFriction);
movementVector.z += (1f - hitNormal.y) * hitNormal.z * (speed - slideFriction);
}
// check if the controller is grounded and above slope limit
// if player is grounded and above slope limit
// player has to slide
if (characterController.isGrounded)
{
currentSlope = Vector3.Angle(Vector3.up, hitNormal);
shouldSlide = currentSlope >= characterController.slopeLimit;
}
jumpInput = false;
}
}

39
UOP1_Project/Assets/Scripts/Characters/Protagonist.cs


using UnityEngine;
/// <summary>
/// <para>This class listens to the input and it deposits it on the <c>Character</c> component, ready to be used by the <c>StateMachine</c></para>
/// </summary>
public InputReader inputReader;
[SerializeField] private InputReader _inputReader = default;
private Character charScript;
private Vector2 previousMovementInput;
private bool controlsEnabled = true;
private Character _charScript;
private Vector2 _previousMovementInput;
charScript = GetComponent<Character>();
_charScript = GetComponent<Character>();
inputReader.jumpEvent += OnJumpInitiated;
inputReader.jumpCanceledEvent += OnJumpCanceled;
inputReader.moveEvent += OnMove;
_inputReader.jumpEvent += OnJumpInitiated;
_inputReader.jumpCanceledEvent += OnJumpCanceled;
_inputReader.moveEvent += OnMove;
//...
}

inputReader.jumpEvent -= OnJumpInitiated;
inputReader.jumpCanceledEvent -= OnJumpCanceled;
inputReader.moveEvent -= OnMove;
_inputReader.jumpEvent -= OnJumpInitiated;
_inputReader.jumpCanceledEvent -= OnJumpCanceled;
_inputReader.moveEvent -= OnMove;
//...
}

cameraRight.y = 0f;
//Use the two axes, modulated by the corresponding inputs, and construct the final vector
Vector3 adjustedMovement = cameraRight.normalized * previousMovementInput.x +
cameraForward.normalized * previousMovementInput.y;
Vector3 adjustedMovement = cameraRight.normalized * _previousMovementInput.x +
cameraForward.normalized * _previousMovementInput.y;
charScript.Move(Vector3.ClampMagnitude(adjustedMovement, 1f));
_charScript.Move(Vector3.ClampMagnitude(adjustedMovement, 1f));
}
//---- EVENT LISTENERS ----

if (controlsEnabled)
previousMovementInput = movement;
_previousMovementInput = movement;
if (controlsEnabled)
charScript.Jump();
_charScript.Jump();
if (controlsEnabled)
charScript.CancelJump();
_charScript.CancelJump();
}
}

2
UOP1_Project/Assets/Scripts/StateMachine/Core/IStateComponent.cs


namespace DeivSky.StateMachine
namespace UOP1.StateMachine
{
interface IStateComponent
{

2
UOP1_Project/Assets/Scripts/StateMachine/Core/State.cs


namespace DeivSky.StateMachine
namespace UOP1.StateMachine
{
public class State
{

2
UOP1_Project/Assets/Scripts/StateMachine/Core/StateAction.cs


namespace DeivSky.StateMachine
namespace UOP1.StateMachine
{
/// <summary>
/// An object representing an action.

2
UOP1_Project/Assets/Scripts/StateMachine/Core/StateCondition.cs


namespace DeivSky.StateMachine
namespace UOP1.StateMachine
{
/// <summary>
/// Class that represents a conditional statement.

2
UOP1_Project/Assets/Scripts/StateMachine/Core/StateMachine.cs


using System.Collections.Generic;
using UnityEngine;
namespace DeivSky.StateMachine
namespace UOP1.StateMachine
{
public class StateMachine : MonoBehaviour
{

2
UOP1_Project/Assets/Scripts/StateMachine/Core/StateTransition.cs


namespace DeivSky.StateMachine
namespace UOP1.StateMachine
{
public class StateTransition : IStateComponent
{

2
UOP1_Project/Assets/Scripts/StateMachine/ScriptableObjects/StateActionSO.cs


using System.Collections.Generic;
using UnityEngine;
namespace DeivSky.StateMachine.ScriptableObjects
namespace UOP1.StateMachine.ScriptableObjects
{
public abstract class StateActionSO : ScriptableObject
{

2
UOP1_Project/Assets/Scripts/StateMachine/ScriptableObjects/StateConditionSO.cs


using System.Collections.Generic;
using UnityEngine;
namespace DeivSky.StateMachine.ScriptableObjects
namespace UOP1.StateMachine.ScriptableObjects
{
public abstract class StateConditionSO : ScriptableObject
{

2
UOP1_Project/Assets/Scripts/StateMachine/ScriptableObjects/StateSO.cs


using System.Collections.Generic;
using UnityEngine;
namespace DeivSky.StateMachine.ScriptableObjects
namespace UOP1.StateMachine.ScriptableObjects
{
[CreateAssetMenu(fileName = "New State", menuName = "State Machines/State")]
public class StateSO : ScriptableObject

2
UOP1_Project/Assets/Scripts/StateMachine/ScriptableObjects/StateTransitionSO.cs


using System.Collections.Generic;
using UnityEngine;
namespace DeivSky.StateMachine.ScriptableObjects
namespace UOP1.StateMachine.ScriptableObjects
{
[CreateAssetMenu(fileName = "New Transition", menuName = "State Machines/Transition")]
public class StateTransitionSO : ScriptableObject

194
UOP1_Project/ProjectSettings/InputManager.asset


InputManager:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Axes: []
m_Axes:
- serializedVersion: 3
m_Name: Enable Debug Button 1
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: left ctrl
altNegativeButton:
altPositiveButton: joystick button 8
gravity: 0
dead: 0
sensitivity: 0
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Enable Debug Button 2
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: backspace
altNegativeButton:
altPositiveButton: joystick button 9
gravity: 0
dead: 0
sensitivity: 0
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Debug Reset
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: left alt
altNegativeButton:
altPositiveButton: joystick button 1
gravity: 0
dead: 0
sensitivity: 0
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Debug Next
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: page down
altNegativeButton:
altPositiveButton: joystick button 5
gravity: 0
dead: 0
sensitivity: 0
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Debug Previous
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: page up
altNegativeButton:
altPositiveButton: joystick button 4
gravity: 0
dead: 0
sensitivity: 0
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Debug Validate
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: return
altNegativeButton:
altPositiveButton: joystick button 0
gravity: 0
dead: 0
sensitivity: 0
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Debug Persistent
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: right shift
altNegativeButton:
altPositiveButton: joystick button 2
gravity: 0
dead: 0
sensitivity: 0
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Debug Multiplier
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: left shift
altNegativeButton:
altPositiveButton: joystick button 3
gravity: 0
dead: 0
sensitivity: 0
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Debug Horizontal
descriptiveName:
descriptiveNegativeName:
negativeButton: left
positiveButton: right
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Debug Vertical
descriptiveName:
descriptiveNegativeName:
negativeButton: down
positiveButton: up
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Debug Vertical
descriptiveName:
descriptiveNegativeName:
negativeButton: down
positiveButton: up
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 2
axis: 6
joyNum: 0
- serializedVersion: 3
m_Name: Debug Horizontal
descriptiveName:
descriptiveNegativeName:
negativeButton: left
positiveButton: right
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 2
axis: 5
joyNum: 0

4
.gitignore


//The purpose of this additional .gitignore is to catch files/directories to ignore in the very root folder of the .git repo
# Visual Studio cache directory
.vs/

8
UOP1_Project/Assets/ScriptableObjects/Protagonist.meta


fileFormatVersion: 2
guid: d230f7c554e81b244bfed84bda39fb82
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
UOP1_Project/Assets/Scripts/Characters/StateMachine.meta


fileFormatVersion: 2
guid: ffc79fdf94115ec4aa7aa8eab84a4afc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

13
UOP1_Project/Assets/Scripts/StateMachine/UOP1.StateMachine.asmdef


{
"name": "UOP1.StateMachine",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

7
UOP1_Project/Assets/Scripts/StateMachine/UOP1.StateMachine.asmdef.meta


fileFormatVersion: 2
guid: 784148ec08432ab4a974dd364656dae9
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions.meta


fileFormatVersion: 2
guid: 8e60fd50527f7904794623b771901faf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

14
UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/ApplyMovementVector.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 816d77d35a7ae9041969e6fdee982452, type: 3}
m_Name: ApplyMovementVector
m_EditorClassIdentifier: Assembly-CSharp::ApplyMovementVectorSO

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/ApplyMovementVector.asset.meta


fileFormatVersion: 2
guid: 47d9da417e68970419335f80f4395239
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

14
UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/Ascend.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d102e2f241954884fba03c7553584369, type: 3}
m_Name: Ascend
m_EditorClassIdentifier:

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/Ascend.asset.meta


fileFormatVersion: 2
guid: 5d9c1bbe4ffcb2146a540998d17b665d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

14
UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/Descend.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bc39053ee56f2cf40af8511f79013117, type: 3}
m_Name: Descend
m_EditorClassIdentifier:

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/Descend.asset.meta


fileFormatVersion: 2
guid: 5d442cfcb78da8b418d6ae3e93e5748e
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

15
UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/GroundGravity.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5e724f945a0fb204fa0f39919afe653b, type: 3}
m_Name: GroundGravity
m_EditorClassIdentifier:
_verticalPull: -5

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/GroundGravity.asset.meta


fileFormatVersion: 2
guid: bd85c54d16eb60c4c99504f1679af851
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

15
UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/MoveInTheAir.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 09fcb347b6cb3524c9f59fbde36ec7c7, type: 3}
m_Name: MoveInTheAir
m_EditorClassIdentifier:
_speed: 6

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/MoveInTheAir.asset.meta


fileFormatVersion: 2
guid: f1f9b67c2b957d74dae6555b3598ae49
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

15
UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/Rotate.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8c2b40ff7519a5e41a2dc48c2aca516c, type: 3}
m_Name: Rotate
m_EditorClassIdentifier:
_turnSmoothTime: 0.2

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/Rotate.asset.meta


fileFormatVersion: 2
guid: 096d532f9a47f3145892efa1c4322e72
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

15
UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/RotateFast.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8c2b40ff7519a5e41a2dc48c2aca516c, type: 3}
m_Name: RotateFast
m_EditorClassIdentifier:
_turnSmoothTime: 0.1

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/RotateFast.asset.meta


fileFormatVersion: 2
guid: 4badb7afa3370ba4d8a229584c5c744f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

15
UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/Slide.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3d6639e9199e4ec44852fe925b2dc470, type: 3}
m_Name: Slide
m_EditorClassIdentifier:
_slideSpeed: 10

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/Slide.asset.meta


fileFormatVersion: 2
guid: 9e558dc250163db40a4e1f7241ee15c2
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

15
UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/SlidingGravity.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5e724f945a0fb204fa0f39919afe653b, type: 3}
m_Name: SlidingGravity
m_EditorClassIdentifier:
_verticalPull: -10

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/SlidingGravity.asset.meta


fileFormatVersion: 2
guid: 088f3e34793299349983d53aaf39e5e3
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

15
UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/Walk.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 09fcb347b6cb3524c9f59fbde36ec7c7, type: 3}
m_Name: Walk
m_EditorClassIdentifier:
_speed: 8

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Actions/Walk.asset.meta


fileFormatVersion: 2
guid: 6a9da1e686e8c3142bcbcc7ccb5bd5ac
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions.meta


fileFormatVersion: 2
guid: c2c72c7f1f1e1464fa361f64a7b618bc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

14
UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/HasHitHead.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 07e6889b70ab561458e46326d9c2a88b, type: 3}
m_Name: HasHitHead
m_EditorClassIdentifier:

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/HasHitHead.asset.meta


fileFormatVersion: 2
guid: 41dbff2af0b6f7141a32bb464309ba69
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

14
UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/IsGrounded.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 953dea50bde69be4fb0df0c3a49eef08, type: 3}
m_Name: IsGrounded
m_EditorClassIdentifier:

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/IsGrounded.asset.meta


fileFormatVersion: 2
guid: c7258bdb2558a214f916c8b5b3c0fa1f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

14
UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/IsHoldingJump.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: aea20a61197822e49aaa66318da39267, type: 3}
m_Name: IsHoldingJump
m_EditorClassIdentifier:

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/IsHoldingJump.asset.meta


fileFormatVersion: 2
guid: 620f4efd93744084a8ac9ba272f093dc
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

15
UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/IsMoving.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fc2d5ccac974a0d41a92a30245aa08eb, type: 3}
m_Name: IsMoving
m_EditorClassIdentifier: Assembly-CSharp::StartMovingConditionSO
_treshold: 0.02

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/IsMoving.asset.meta


fileFormatVersion: 2
guid: a79b812272ab8314aa305b39f9a2740a
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

14
UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/IsSliding.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9352ebfadd39e754e86b2aa1daffdca0, type: 3}
m_Name: IsSliding
m_EditorClassIdentifier:

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/IsSliding.asset.meta


fileFormatVersion: 2
guid: c5090b215e4f1594f9d1ef6680cd15bb
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

15
UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/JumpHoldTimer.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8139f9f328ed1144690b7a9ffca2d5b4, type: 3}
m_Name: JumpHoldTimer
m_EditorClassIdentifier:
_timerLength: 0.4

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Conditions/JumpHoldTimer.asset.meta


fileFormatVersion: 2
guid: bf6a2f4642738ac4f8e84bcdf1cb5f93
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/States.meta


fileFormatVersion: 2
guid: 804b3b4960b69144db0d6ee7bb8249bb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

20
UOP1_Project/Assets/ScriptableObjects/Protagonist/States/Idle.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 35432205b9a6a374bbbfe6b7cac92179, type: 3}
m_Name: Idle
m_EditorClassIdentifier:
_actions:
- {fileID: 11400000, guid: bd85c54d16eb60c4c99504f1679af851, type: 2}
- {fileID: 11400000, guid: 47d9da417e68970419335f80f4395239, type: 2}
_transitions:
- {fileID: 11400000, guid: 15394873b380a284bbf425c98e1f7ff5, type: 2}
- {fileID: 11400000, guid: a397ed7ab7a1ef24082946a116ba98ed, type: 2}

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/States/Idle.asset.meta


fileFormatVersion: 2
guid: e128814ff6dbf63449bbc4dc8b6dc066
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

22
UOP1_Project/Assets/ScriptableObjects/Protagonist/States/JumpAscending.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 35432205b9a6a374bbbfe6b7cac92179, type: 3}
m_Name: JumpAscending
m_EditorClassIdentifier:
_actions:
- {fileID: 11400000, guid: f1f9b67c2b957d74dae6555b3598ae49, type: 2}
- {fileID: 11400000, guid: 5d9c1bbe4ffcb2146a540998d17b665d, type: 2}
- {fileID: 11400000, guid: 47d9da417e68970419335f80f4395239, type: 2}
- {fileID: 11400000, guid: 096d532f9a47f3145892efa1c4322e72, type: 2}
_transitions:
- {fileID: 11400000, guid: 06d55bd43e60a1a469545b18bca1061c, type: 2}
- {fileID: 11400000, guid: d0d2423b580ea5a4789dcee21f62cba6, type: 2}

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/States/JumpAscending.asset.meta


fileFormatVersion: 2
guid: 0aa906b71b1b4504d950f5ee8e1f06e8
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

22
UOP1_Project/Assets/ScriptableObjects/Protagonist/States/JumpDescending.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 35432205b9a6a374bbbfe6b7cac92179, type: 3}
m_Name: JumpDescending
m_EditorClassIdentifier:
_actions:
- {fileID: 11400000, guid: f1f9b67c2b957d74dae6555b3598ae49, type: 2}
- {fileID: 11400000, guid: 5d442cfcb78da8b418d6ae3e93e5748e, type: 2}
- {fileID: 11400000, guid: 47d9da417e68970419335f80f4395239, type: 2}
- {fileID: 11400000, guid: 096d532f9a47f3145892efa1c4322e72, type: 2}
_transitions:
- {fileID: 11400000, guid: 426d4a126aac5f94abff16fd4fd22450, type: 2}
- {fileID: 11400000, guid: bdbd98a2bcdc25c47bdae39b7ab3bac6, type: 2}

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/States/JumpDescending.asset.meta


fileFormatVersion: 2
guid: c57ed1dc57a890943b2648ca8a581075
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

21
UOP1_Project/Assets/ScriptableObjects/Protagonist/States/Sliding.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 35432205b9a6a374bbbfe6b7cac92179, type: 3}
m_Name: Sliding
m_EditorClassIdentifier:
_actions:
- {fileID: 11400000, guid: 088f3e34793299349983d53aaf39e5e3, type: 2}
- {fileID: 11400000, guid: 9e558dc250163db40a4e1f7241ee15c2, type: 2}
- {fileID: 11400000, guid: 47d9da417e68970419335f80f4395239, type: 2}
- {fileID: 11400000, guid: 4badb7afa3370ba4d8a229584c5c744f, type: 2}
_transitions:
- {fileID: 11400000, guid: d65431b4fa02b494ab91bafd68cb5a8f, type: 2}

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/States/Sliding.asset.meta


fileFormatVersion: 2
guid: 4c2c0dc4f7ee62b4d95b20ac3dce281e
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

24
UOP1_Project/Assets/ScriptableObjects/Protagonist/States/Walking.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 35432205b9a6a374bbbfe6b7cac92179, type: 3}
m_Name: Walking
m_EditorClassIdentifier:
_actions:
- {fileID: 11400000, guid: 6a9da1e686e8c3142bcbcc7ccb5bd5ac, type: 2}
- {fileID: 11400000, guid: bd85c54d16eb60c4c99504f1679af851, type: 2}
- {fileID: 11400000, guid: 47d9da417e68970419335f80f4395239, type: 2}
- {fileID: 11400000, guid: 096d532f9a47f3145892efa1c4322e72, type: 2}
_transitions:
- {fileID: 11400000, guid: 41433dadcfe624b41a29409bd2049c85, type: 2}
- {fileID: 11400000, guid: a397ed7ab7a1ef24082946a116ba98ed, type: 2}
- {fileID: 11400000, guid: 54b0ebefbe8767c41a7e981ea0857f68, type: 2}
- {fileID: 11400000, guid: 06d55bd43e60a1a469545b18bca1061c, type: 2}

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/States/Walking.asset.meta


fileFormatVersion: 2
guid: 027d32476800b3543b2f5446a59054c8
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions.meta


fileFormatVersion: 2
guid: 7273e93cd813a8947b64537b38daed30
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

19
UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/BeginJump.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9e1893bf30b6f554a9d80007ee336691, type: 3}
m_Name: BeginJump
m_EditorClassIdentifier:
_targetState: {fileID: 11400000, guid: 0aa906b71b1b4504d950f5ee8e1f06e8, type: 2}
_conditions:
- ExpectedResult: 0
Condition: {fileID: 11400000, guid: 620f4efd93744084a8ac9ba272f093dc, type: 2}
Operator: 0

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/BeginJump.asset.meta


fileFormatVersion: 2
guid: a397ed7ab7a1ef24082946a116ba98ed
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

22
UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/BeginJumpDescent.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9e1893bf30b6f554a9d80007ee336691, type: 3}
m_Name: BeginJumpDescent
m_EditorClassIdentifier:
_targetState: {fileID: 11400000, guid: c57ed1dc57a890943b2648ca8a581075, type: 2}
_conditions:
- ExpectedResult: 1
Condition: {fileID: 11400000, guid: 620f4efd93744084a8ac9ba272f093dc, type: 2}
Operator: 1
- ExpectedResult: 0
Condition: {fileID: 11400000, guid: bf6a2f4642738ac4f8e84bcdf1cb5f93, type: 2}
Operator: 0

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/BeginJumpDescent.asset.meta


fileFormatVersion: 2
guid: 06d55bd43e60a1a469545b18bca1061c
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

19
UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/HitHead.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9e1893bf30b6f554a9d80007ee336691, type: 3}
m_Name: HitHead
m_EditorClassIdentifier:
_targetState: {fileID: 11400000, guid: c57ed1dc57a890943b2648ca8a581075, type: 2}
_conditions:
- ExpectedResult: 0
Condition: {fileID: 11400000, guid: 41dbff2af0b6f7141a32bb464309ba69, type: 2}
Operator: 0

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/HitHead.asset.meta


fileFormatVersion: 2
guid: d0d2423b580ea5a4789dcee21f62cba6
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

22
UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/LandIdle.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9e1893bf30b6f554a9d80007ee336691, type: 3}
m_Name: LandIdle
m_EditorClassIdentifier:
_targetState: {fileID: 11400000, guid: e128814ff6dbf63449bbc4dc8b6dc066, type: 2}
_conditions:
- ExpectedResult: 0
Condition: {fileID: 11400000, guid: c7258bdb2558a214f916c8b5b3c0fa1f, type: 2}
Operator: 0
- ExpectedResult: 1
Condition: {fileID: 11400000, guid: a79b812272ab8314aa305b39f9a2740a, type: 2}
Operator: 0

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/LandIdle.asset.meta


fileFormatVersion: 2
guid: bdbd98a2bcdc25c47bdae39b7ab3bac6
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

22
UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/LandWalking.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9e1893bf30b6f554a9d80007ee336691, type: 3}
m_Name: LandWalking
m_EditorClassIdentifier:
_targetState: {fileID: 11400000, guid: 027d32476800b3543b2f5446a59054c8, type: 2}
_conditions:
- ExpectedResult: 0
Condition: {fileID: 11400000, guid: c7258bdb2558a214f916c8b5b3c0fa1f, type: 2}
Operator: 0
- ExpectedResult: 0
Condition: {fileID: 11400000, guid: a79b812272ab8314aa305b39f9a2740a, type: 2}
Operator: 0

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/LandWalking.asset.meta


fileFormatVersion: 2
guid: 426d4a126aac5f94abff16fd4fd22450
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

19
UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/StartSliding.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9e1893bf30b6f554a9d80007ee336691, type: 3}
m_Name: StartSliding
m_EditorClassIdentifier:
_targetState: {fileID: 11400000, guid: 4c2c0dc4f7ee62b4d95b20ac3dce281e, type: 2}
_conditions:
- ExpectedResult: 0
Condition: {fileID: 11400000, guid: c5090b215e4f1594f9d1ef6680cd15bb, type: 2}
Operator: 0

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/StartSliding.asset.meta


fileFormatVersion: 2
guid: 54b0ebefbe8767c41a7e981ea0857f68
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

19
UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/StartWalking.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9e1893bf30b6f554a9d80007ee336691, type: 3}
m_Name: StartWalking
m_EditorClassIdentifier:
_targetState: {fileID: 11400000, guid: 027d32476800b3543b2f5446a59054c8, type: 2}
_conditions:
- ExpectedResult: 0
Condition: {fileID: 11400000, guid: a79b812272ab8314aa305b39f9a2740a, type: 2}
Operator: 0

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/StartWalking.asset.meta


fileFormatVersion: 2
guid: 15394873b380a284bbf425c98e1f7ff5
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

19
UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/StopSliding.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9e1893bf30b6f554a9d80007ee336691, type: 3}
m_Name: StopSliding
m_EditorClassIdentifier:
_targetState: {fileID: 11400000, guid: e128814ff6dbf63449bbc4dc8b6dc066, type: 2}
_conditions:
- ExpectedResult: 1
Condition: {fileID: 11400000, guid: c5090b215e4f1594f9d1ef6680cd15bb, type: 2}
Operator: 0

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/StopSliding.asset.meta


fileFormatVersion: 2
guid: d65431b4fa02b494ab91bafd68cb5a8f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

19
UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/StopWalking.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9e1893bf30b6f554a9d80007ee336691, type: 3}
m_Name: StopWalking
m_EditorClassIdentifier:
_targetState: {fileID: 11400000, guid: e128814ff6dbf63449bbc4dc8b6dc066, type: 2}
_conditions:
- ExpectedResult: 1
Condition: {fileID: 11400000, guid: a79b812272ab8314aa305b39f9a2740a, type: 2}
Operator: 0

8
UOP1_Project/Assets/ScriptableObjects/Protagonist/Transitions/StopWalking.asset.meta


fileFormatVersion: 2
guid: 41433dadcfe624b41a29409bd2049c85
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

8
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions.meta


fileFormatVersion: 2
guid: 5709933eec4549d4f9c4389785d44d3d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

24
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/ApplyMovementVectorActionSO.cs


using UnityEngine;
using UOP1.StateMachine;
using UOP1.StateMachine.ScriptableObjects;
[CreateAssetMenu(fileName = "ApplyMovementVector", menuName = "State Machines/Actions/Apply Movement Vector")]
public class ApplyMovementVectorActionSO : StateActionSO<ApplyMovementVectorAction> { }
public class ApplyMovementVectorAction : StateAction
{
//Component references
private Character _characterScript;
private CharacterController _characterController;
public override void Awake(StateMachine stateMachine)
{
_characterScript = stateMachine.GetComponent<Character>();
_characterController = stateMachine.GetComponent<CharacterController>();
}
public override void OnUpdate()
{
_characterController.Move(_characterScript.movementVector * Time.deltaTime);
}
}

11
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/ApplyMovementVectorActionSO.cs.meta


fileFormatVersion: 2
guid: 816d77d35a7ae9041969e6fdee982452
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

50
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/AscendActionSO.cs


using UnityEngine;
using UOP1.StateMachine;
using UOP1.StateMachine.ScriptableObjects;
[CreateAssetMenu(fileName = "Ascend", menuName = "State Machines/Actions/Ascend")]
public class AscendActionSO : StateActionSO
{
[Tooltip("The initial upwards push when pressing jump. This is injected into verticalMovement, and gradually cancelled by gravity")]
[SerializeField] private float _initialJumpForce = 10f;
protected override StateAction CreateAction() => new AscendAction(_initialJumpForce);
}
public class AscendAction : StateAction
{
//Component references
private Character _characterScript;
private float _verticalMovement;
private float _gravityContributionMultiplier;
private float _initialJumpForce;
private const float GRAVITY_COMEBACK_MULTIPLIER = 15f;
private const float GRAVITY_DIVIDER = .6f;
private const float GRAVITY_MULTIPLIER = 5f;
public override void Awake(StateMachine stateMachine)
{
_characterScript = stateMachine.GetComponent<Character>();
}
public AscendAction(float initialJumpForce)
{
_initialJumpForce = initialJumpForce;
}
public override void OnStateEnter()
{
_verticalMovement = _initialJumpForce;
}
public override void OnUpdate()
{
_gravityContributionMultiplier += Time.deltaTime * GRAVITY_COMEBACK_MULTIPLIER;
_gravityContributionMultiplier *= GRAVITY_DIVIDER; //Reduce the gravity effect
_verticalMovement += Physics.gravity.y * GRAVITY_MULTIPLIER * Time.deltaTime * _gravityContributionMultiplier;
//Note that even if it's added, the above value is negative due to Physics.gravity.y
_characterScript.movementVector.y = _verticalMovement;
}
}

11
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/AscendActionSO.cs.meta


fileFormatVersion: 2
guid: d102e2f241954884fba03c7553584369
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

45
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/DescendActionSO.cs


using UnityEngine;
using UOP1.StateMachine;
using UOP1.StateMachine.ScriptableObjects;
[CreateAssetMenu(fileName = "Descend", menuName = "State Machines/Actions/Descend")]
public class DescendActionSO : StateActionSO
{
protected override StateAction CreateAction() => new DescendAction();
}
public class DescendAction : StateAction
{
//Component references
private Character _characterScript;
private float _verticalMovement;
private const float GRAVITY_MULTIPLIER = 5f;
private const float MAX_FALL_SPEED = -50f;
private const float MAX_RISE_SPEED = 100f;
public override void Awake(StateMachine stateMachine)
{
_characterScript = stateMachine.GetComponent<Character>();
}
public override void OnStateEnter()
{
_verticalMovement = _characterScript.movementVector.y;
//Prevents a double jump if the player keeps holding the jump button
//Basically it "consumes" the input
_characterScript.jumpInput = false;
}
public override void OnUpdate()
{
_verticalMovement += Physics.gravity.y * GRAVITY_MULTIPLIER * Time.deltaTime;
//Note that even if it's added, the above value is negative due to Physics.gravity.y
//Cap the maximum so the player doesn't reach incredible speeds when freefalling from high positions
_verticalMovement = Mathf.Clamp(_verticalMovement, MAX_FALL_SPEED, MAX_RISE_SPEED);
_characterScript.movementVector.y = _verticalMovement;
}
}

11
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/DescendActionSO.cs.meta


fileFormatVersion: 2
guid: bc39053ee56f2cf40af8511f79013117
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

35
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/GroundGravityActionSO.cs


using UnityEngine;
using UOP1.StateMachine;
using UOP1.StateMachine.ScriptableObjects;
[CreateAssetMenu(fileName = "GroundGravity", menuName = "State Machines/Actions/Ground Gravity")]
public class GroundGravityActionSO : StateActionSO
{
[Tooltip("Vertical movement pulling down the player to keep it anchored to the ground.")]
[SerializeField] private float _verticalPull = -5f;
protected override StateAction CreateAction() => new GroundGravityAction(_verticalPull);
}
public class GroundGravityAction : StateAction
{
//Component references
private Character _characterScript;
private float _verticalPull;
public GroundGravityAction(float slideSpeed)
{
_verticalPull = slideSpeed;
}
public override void Awake(StateMachine stateMachine)
{
_characterScript = stateMachine.GetComponent<Character>();
}
public override void OnUpdate()
{
_characterScript.movementVector.y = _verticalPull;
}
}

11
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/GroundGravityActionSO.cs.meta


fileFormatVersion: 2
guid: 5e724f945a0fb204fa0f39919afe653b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

部分文件因为文件数量过多而无法显示

正在加载...
取消
保存