Checkpoint

This commit is contained in:
2026-03-19 21:34:27 +01:00
parent 5b8fecd593
commit 532ede9714
9 changed files with 531 additions and 19 deletions

Binary file not shown.

View File

@@ -0,0 +1,110 @@
fileFormatVersion: 2
guid: 0605a18a03830e647ab81cfa4bdfbfa4
ModelImporter:
serializedVersion: 24200
internalIDToNameTable: []
externalObjects: {}
materials:
materialImportMode: 2
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
removeConstantScaleCurves: 0
motionNodeName:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations: []
isReadable: 0
meshes:
lODScreenPercentages: []
globalScale: 1
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
sortHierarchyByName: 1
importPhysicalCameras: 1
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importLights: 1
nodeNameCollisionStrategy: 1
fileIdsGeneration: 2
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
keepQuads: 0
weldVertices: 1
bakeAxisConversion: 0
preserveHierarchy: 0
skinWeightsMode: 0
maxBonesPerVertex: 4
minBoneWeight: 0.001
optimizeBones: 1
generateMeshLods: 0
meshLodGenerationFlags: 0
maximumMeshLod: -1
meshOptimizationFlags: -1
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVMarginMethod: 1
secondaryUVMinLightmapResolution: 40
secondaryUVMinObjectScale: 1
secondaryUVPackMargin: 4
useFileScale: 1
strictVertexDataChecks: 0
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
referencedClips: []
importAnimation: 1
humanDescription:
serializedVersion: 3
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
globalScale: 1
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
autoGenerateAvatarMappingIfUnspecified: 1
animationType: 2
humanoidOversampling: 1
avatarSetup: 0
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
importBlendShapeDeformPercent: 1
remapMaterialsIfMaterialImportModeIsNone: 0
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,188 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &2324986646165008912
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: -9178229380372946182, guid: 0605a18a03830e647ab81cfa4bdfbfa4, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 0605a18a03830e647ab81cfa4bdfbfa4, type: 3}
propertyPath: m_LocalPosition.x
value: 1.787
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 0605a18a03830e647ab81cfa4bdfbfa4, type: 3}
propertyPath: m_LocalPosition.y
value: 5.2187877
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 0605a18a03830e647ab81cfa4bdfbfa4, type: 3}
propertyPath: m_LocalPosition.z
value: 18.23
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 0605a18a03830e647ab81cfa4bdfbfa4, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 0605a18a03830e647ab81cfa4bdfbfa4, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 0605a18a03830e647ab81cfa4bdfbfa4, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 0605a18a03830e647ab81cfa4bdfbfa4, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 0605a18a03830e647ab81cfa4bdfbfa4, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 0605a18a03830e647ab81cfa4bdfbfa4, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 0605a18a03830e647ab81cfa4bdfbfa4, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 919132149155446097, guid: 0605a18a03830e647ab81cfa4bdfbfa4, type: 3}
propertyPath: m_Name
value: Checkpoint
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: 0605a18a03830e647ab81cfa4bdfbfa4, type: 3}
insertIndex: -1
addedObject: {fileID: 410636927176536248}
- targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: 0605a18a03830e647ab81cfa4bdfbfa4, type: 3}
insertIndex: -1
addedObject: {fileID: 5314474917760840187}
- targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: 0605a18a03830e647ab81cfa4bdfbfa4, type: 3}
insertIndex: -1
addedObject: {fileID: 6519834558772459323}
m_SourcePrefab: {fileID: 100100000, guid: 0605a18a03830e647ab81cfa4bdfbfa4, type: 3}
--- !u!1 &2370127092883919082 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: -9178229380372946182, guid: 0605a18a03830e647ab81cfa4bdfbfa4, type: 3}
m_PrefabInstance: {fileID: 2324986646165008912}
m_PrefabAsset: {fileID: 0}
--- !u!1 &3208087788540661569 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: 0605a18a03830e647ab81cfa4bdfbfa4, type: 3}
m_PrefabInstance: {fileID: 2324986646165008912}
m_PrefabAsset: {fileID: 0}
--- !u!65 &410636927176536248
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3208087788540661569}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 1
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Size: {x: 0.4, y: 1, z: 0.4}
m_Center: {x: 0, y: 0.5, z: 0}
--- !u!114 &5314474917760840187
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3208087788540661569}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6e20e5bd115065c42b0cd4c112c16203, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::PlayerEvent
OnPlayerEnter:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 6519834558772459323}
m_TargetAssemblyTypeName: Checkpoint, Assembly-CSharp
m_MethodName: Activate
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 1
m_CallState: 2
OnPlayerExit:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine
m_MethodName: SetActive
m_Mode: 6
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!114 &6519834558772459323
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3208087788540661569}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 83324a7ce5cc7e64a9ff596a58bf010b, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::Checkpoint
_isDefault: 0
_onActivated:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2370127092883919082}
m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine
m_MethodName: SetActive
m_Mode: 6
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 1
m_CallState: 2
_onDisable:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2370127092883919082}
m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine
m_MethodName: SetActive
m_Mode: 6
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 14737cad78e22fa4da8f66ee1423de0f
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -366,6 +366,7 @@ MonoBehaviour:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
PlayOnAwake: 1
Duration: 0.5
TimeOffset: 0.2
Translation: {x: 0, y: 0, z: 0}
@@ -650,6 +651,7 @@ MonoBehaviour:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
PlayOnAwake: 1
Duration: 0.5
TimeOffset: 0.4
Translation: {x: 0, y: 0, z: 0}
@@ -1689,6 +1691,7 @@ MonoBehaviour:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
PlayOnAwake: 1
Duration: 1
TimeOffset: 0
Translation: {x: 0, y: 0, z: 0}
@@ -1740,6 +1743,7 @@ MonoBehaviour:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
PlayOnAwake: 1
Duration: 1
TimeOffset: 0
Translation: {x: 0, y: 3, z: 0}
@@ -1948,6 +1952,7 @@ MonoBehaviour:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
PlayOnAwake: 1
Duration: 2
TimeOffset: 0
Translation: {x: 0, y: 11, z: 0}
@@ -2161,6 +2166,7 @@ MonoBehaviour:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
PlayOnAwake: 1
Duration: 7
TimeOffset: 0
Translation: {x: 0, y: 10, z: 0}
@@ -2743,6 +2749,67 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1080756049}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1001 &1081482970
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 2868435020841506299, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_LocalPosition.x
value: 1.1496711
objectReference: {fileID: 0}
- target: {fileID: 2868435020841506299, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_LocalPosition.y
value: 1.0900003
objectReference: {fileID: 0}
- target: {fileID: 2868435020841506299, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_LocalPosition.z
value: -1.424969
objectReference: {fileID: 0}
- target: {fileID: 2868435020841506299, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2868435020841506299, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 2868435020841506299, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 2868435020841506299, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 2868435020841506299, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2868435020841506299, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2868435020841506299, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3208087788540661569, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_Name
value: Checkpoint_00
objectReference: {fileID: 0}
- target: {fileID: 6519834558772459323, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: _isDefault
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
--- !u!1 &1085210505
GameObject:
m_ObjectHideFlags: 0
@@ -3105,6 +3172,7 @@ MonoBehaviour:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
PlayOnAwake: 1
Duration: 0.5
TimeOffset: 1
Translation: {x: 0, y: 0, z: 0}
@@ -3382,6 +3450,7 @@ MonoBehaviour:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
PlayOnAwake: 1
Duration: 0.5
TimeOffset: 0.6
Translation: {x: 0, y: 0, z: 0}
@@ -3547,6 +3616,7 @@ MonoBehaviour:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
PlayOnAwake: 1
Duration: 2
TimeOffset: 0
Translation: {x: 0, y: 5, z: 6}
@@ -4032,6 +4102,7 @@ MonoBehaviour:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
PlayOnAwake: 1
Duration: 0.5
TimeOffset: 0.8
Translation: {x: 0, y: 0, z: 0}
@@ -5176,6 +5247,7 @@ MonoBehaviour:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
PlayOnAwake: 1
Duration: 0.5
TimeOffset: 0
Translation: {x: 0, y: 0, z: 0}
@@ -6066,6 +6138,63 @@ PrefabInstance:
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: dfb5576e46653d9419747f6c7e441ee4, type: 3}
--- !u!1001 &3500778195936868464
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 2868435020841506299, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_LocalPosition.x
value: 1.787
objectReference: {fileID: 0}
- target: {fileID: 2868435020841506299, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_LocalPosition.y
value: 5.2187877
objectReference: {fileID: 0}
- target: {fileID: 2868435020841506299, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_LocalPosition.z
value: 18.23
objectReference: {fileID: 0}
- target: {fileID: 2868435020841506299, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2868435020841506299, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 2868435020841506299, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 2868435020841506299, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 2868435020841506299, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2868435020841506299, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2868435020841506299, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3208087788540661569, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
propertyPath: m_Name
value: Checkpoint_01
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 14737cad78e22fa4da8f66ee1423de0f, type: 3}
--- !u!1001 &5497189567890878294
PrefabInstance:
m_ObjectHideFlags: 0
@@ -6088,7 +6217,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 2074228021127610768, guid: f4beaf6954e188347a7c1e7e772d364e, type: 3}
propertyPath: m_LocalPosition.z
value: -8.08
value: -5.61
objectReference: {fileID: 0}
- target: {fileID: 2074228021127610768, guid: f4beaf6954e188347a7c1e7e772d364e, type: 3}
propertyPath: m_LocalRotation.w
@@ -6360,3 +6489,5 @@ SceneRoots:
- {fileID: 55113320}
- {fileID: 604692791}
- {fileID: 1798386216}
- {fileID: 1081482970}
- {fileID: 3500778195936868464}

View File

@@ -1,16 +1,35 @@
using UnityEngine;
using UnityEngine.Events;
public class Checkpoint : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
public static Checkpoint Active { get; private set; }
[SerializeField] private bool _isDefault;
[SerializeField] private UnityEvent _onActivated;
[SerializeField] private UnityEvent _onDisable;
public void Activate()
{
if (Active)
Active.Disable();
Active = this;
_onActivated?.Invoke();
}
// Update is called once per frame
void Update()
public void Disable()
{
if (Active == this)
{
Active = null;
_onDisable?.Invoke();
}
}
void Awake()
{
if (_isDefault)
Activate();
}
}

View File

@@ -1,6 +1,7 @@
using UnityEngine;
using UnityEngine.InputSystem;
using System;
using UnityEngine.Events;
/// <summary>
/// Player controller.
@@ -95,8 +96,8 @@ public class Player : MonoBehaviour
[Tooltip("Current health points")]
public int CurrentHealth;
[Tooltip("Checkpoint for respawn")]
public Checkpoint Checkpoint;
[Tooltip("Event on definitive die")]
public UnityEvent OnDie;
}
[SerializeField] private Settings _settings;
@@ -203,6 +204,8 @@ public class Player : MonoBehaviour
_groundCheckRayOffset = cc.center + Vector3.up * (-cc.height * .5f - cc.skinWidth + _settings.GroundTolerance);
_groundCheckSphereOffset = cc.center + Vector3.up * (-cc.height * .5f + cc.radius - cc.skinWidth - _settings.GroundTolerance);
_groundCheckRadius = cc.radius;
_health.CurrentHealth = _health.MaxHealth;
}
void OnEnable()
@@ -297,16 +300,7 @@ public class Player : MonoBehaviour
_state.CurrentState = PlayerState.Stunned;
if (duration > 0)
Invoke(nameof(RecoverFromStun), duration);
}
/// <summary>
/// Recover from stun.
/// </summary>
public void RecoverFromStun()
{
if (_state.CurrentState == PlayerState.Stunned)
_state.CurrentState = PlayerState.Idle;
Invoke(nameof(Recover), duration);
}
/// <summary>
@@ -319,6 +313,43 @@ public class Player : MonoBehaviour
_state.Velocity = _impulseForce = _persistentForce = _platformVelocity = Vector3.zero;
_state.Ground = null;
_state.CurrentState = PlayerState.Eliminated;
Invoke(nameof(GoToCheckpoint), 2);
}
/// <summary>
/// Recover from stun.
/// </summary>
public void GoToCheckpoint()
{
if (Checkpoint.Active && _health.CurrentHealth > 0)
{
_health.CurrentHealth--;
transform.position = Checkpoint.Active.transform.position;
Debug.Log("Go to last checkpoint");
Recover();
}
else
{
Debug.Log("Player is dead");
_health.OnDie.Invoke();
}
}
/// <summary>
/// Recover from stun.
/// </summary>
public void Recover()
{
if (_state.CurrentState == PlayerState.Stunned ||
_state.CurrentState == PlayerState.Eliminated)
_state.CurrentState = PlayerState.Idle;
_references.Controller.enabled = true;
}
/// <summary>

View File

@@ -0,0 +1,24 @@
using UnityEngine;
using UnityEngine.Events;
public class PlayerEvent : MonoBehaviour
{
public UnityEvent OnPlayerEnter;
public UnityEvent OnPlayerExit;
void OnTriggerEnter(Collider col)
{
if (Player.Instance && col.gameObject == Player.Instance.gameObject)
{
OnPlayerEnter?.Invoke();
}
}
void OnTriggerExit(Collider col)
{
if (Player.Instance && col.gameObject == Player.Instance.gameObject)
{
OnPlayerExit?.Invoke();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6e20e5bd115065c42b0cd4c112c16203