浏览代码

Tweaks and comments

Removed StateMachines scene, fixed a small bug on Sliding when spawning in the air and trying to move
/main
Ciro Continisio 4 年前
当前提交
2cb26091
共有 12 个文件被更改,包括 271 次插入1056 次删除
  1. 67
      UOP1_Project/Assets/Prefabs/Pig.prefab
  2. 15
      UOP1_Project/Assets/Scenes/CharController.unity
  3. 15
      UOP1_Project/Assets/Scripts/Characters/Character.cs
  4. 3
      UOP1_Project/Assets/Scripts/Characters/Protagonist.cs
  5. 5
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/DescendActionSO.cs
  6. 9
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/HasHitHeadConditionSO.cs
  7. 3
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsSlidingConditionSO.cs
  8. 194
      UOP1_Project/ProjectSettings/InputManager.asset
  9. 8
      UOP1_Project/Assets/Scenes/StateMachines.meta
  10. 7
      UOP1_Project/Assets/Scenes/StateMachines.unity.meta
  11. 1001
      UOP1_Project/Assets/Scenes/StateMachines.unity

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

15
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>
public bool jumpInput;
public Vector3 movementInput; //Initial input coming from the Protagonist script
public Vector3 movementVector; //Final movement vector, manipulated by the StateMachine actions
public ControllerColliderHit lastHit;
//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;
private void OnControllerColliderHit(ControllerColliderHit hit)
{

3
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 class Protagonist : MonoBehaviour
{
[SerializeField] private InputReader _inputReader = default;

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


public override void OnStateEnter()
{
_verticalMovement = _characterScript.movementVector.y;
_characterScript.jumpInput = false; //Prevents a double jump if the player keeps holding the jump button
//Prevents a double jump if the player keeps holding the jump button
//Basically it "consumes" the input
_characterScript.jumpInput = false;
}
public override void OnUpdate()

9
UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/HasHitHeadConditionSO.cs


float distance = Mathf.Abs(_characterScript.lastHit.point.y - topPositionY);
if (distance <= permittedDistance)
{
_characterScript.jumpInput = false;
_characterScript.movementVector.y = 0f;
}
public override void OnStateExit()
{
_characterScript.jumpInput = false;
_characterScript.movementVector.y = 0f;
}
}

3
UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsSlidingConditionSO.cs


public override bool Statement()
{
if (_characterScript.lastHit == null)
return false;
float currentSlope = Vector3.Angle(Vector3.up, _characterScript.lastHit.normal);
return (currentSlope >= _characterController.slopeLimit);
}

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

8
UOP1_Project/Assets/Scenes/StateMachines.meta


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

7
UOP1_Project/Assets/Scenes/StateMachines.unity.meta


fileFormatVersion: 2
guid: 2ece9c9d6c19541478faa51f281757a7
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

1001
UOP1_Project/Assets/Scenes/StateMachines.unity
文件差异内容过多而无法显示
查看文件

正在加载...
取消
保存