Quick normal to jumping transition + Camera
This commit is contained in:
parent
df13976d24
commit
c6c92a6e5e
@ -254,6 +254,160 @@ Rigidbody2D:
|
|||||||
m_SleepingMode: 1
|
m_SleepingMode: 1
|
||||||
m_CollisionDetection: 0
|
m_CollisionDetection: 0
|
||||||
m_Constraints: 0
|
m_Constraints: 0
|
||||||
|
--- !u!1 &412174278
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 412174279}
|
||||||
|
- component: {fileID: 412174281}
|
||||||
|
- component: {fileID: 412174280}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: cm
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &412174279
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 412174278}
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0.1217883, y: -1.235689, z: 10.669466}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 519903874}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &412174280
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 412174278}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 6ad980451443d70438faac0bc6c235a0, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_TrackedObjectOffset: {x: 0, y: 0, z: 0}
|
||||||
|
m_LookaheadTime: 0
|
||||||
|
m_LookaheadSmoothing: 0
|
||||||
|
m_LookaheadIgnoreY: 0
|
||||||
|
m_XDamping: 1
|
||||||
|
m_YDamping: 1
|
||||||
|
m_ZDamping: 1
|
||||||
|
m_TargetMovementOnly: 1
|
||||||
|
m_ScreenX: 0.5
|
||||||
|
m_ScreenY: 0.5
|
||||||
|
m_CameraDistance: 10
|
||||||
|
m_DeadZoneWidth: 0
|
||||||
|
m_DeadZoneHeight: 0
|
||||||
|
m_DeadZoneDepth: 0
|
||||||
|
m_UnlimitedSoftZone: 0
|
||||||
|
m_SoftZoneWidth: 0.8
|
||||||
|
m_SoftZoneHeight: 0.8
|
||||||
|
m_BiasX: 0
|
||||||
|
m_BiasY: 0
|
||||||
|
m_CenterOnActivate: 1
|
||||||
|
m_GroupFramingMode: 2
|
||||||
|
m_AdjustmentMode: 0
|
||||||
|
m_GroupFramingSize: 0.8
|
||||||
|
m_MaxDollyIn: 5000
|
||||||
|
m_MaxDollyOut: 5000
|
||||||
|
m_MinimumDistance: 1
|
||||||
|
m_MaximumDistance: 5000
|
||||||
|
m_MinimumFOV: 3
|
||||||
|
m_MaximumFOV: 60
|
||||||
|
m_MinimumOrthoSize: 1
|
||||||
|
m_MaximumOrthoSize: 5000
|
||||||
|
--- !u!114 &412174281
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 412174278}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: ac0b09e7857660247b1477e93731de29, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
--- !u!1 &519903872
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 519903874}
|
||||||
|
- component: {fileID: 519903873}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: VCam
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!114 &519903873
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 519903872}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 45e653bab7fb20e499bda25e1b646fea, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_ExcludedPropertiesInInspector:
|
||||||
|
- m_Script
|
||||||
|
m_LockStageInInspector:
|
||||||
|
m_StreamingVersion: 20170927
|
||||||
|
m_Priority: 10
|
||||||
|
m_StandbyUpdate: 2
|
||||||
|
m_LookAt: {fileID: 1483024674}
|
||||||
|
m_Follow: {fileID: 1483024674}
|
||||||
|
m_Lens:
|
||||||
|
FieldOfView: 60
|
||||||
|
OrthographicSize: 5
|
||||||
|
NearClipPlane: 0.3
|
||||||
|
FarClipPlane: 1000
|
||||||
|
Dutch: 0
|
||||||
|
LensShift: {x: 0, y: 0}
|
||||||
|
m_Transitions:
|
||||||
|
m_BlendHint: 0
|
||||||
|
m_InheritPosition: 0
|
||||||
|
m_OnCameraLive:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_LegacyBlendHint: 0
|
||||||
|
m_ComponentOwner: {fileID: 412174279}
|
||||||
|
--- !u!4 &519903874
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 519903872}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: -10}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children:
|
||||||
|
- {fileID: 412174279}
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 6
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &877291413
|
--- !u!1 &877291413
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -385,6 +539,22 @@ Rigidbody2D:
|
|||||||
m_SleepingMode: 1
|
m_SleepingMode: 1
|
||||||
m_CollisionDetection: 0
|
m_CollisionDetection: 0
|
||||||
m_Constraints: 0
|
m_Constraints: 0
|
||||||
|
--- !u!114 &1483024672 stripped
|
||||||
|
MonoBehaviour:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 1214567908930553592, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 1214567907777892293}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 639be549366b46748bd86eb6cea796a3, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
--- !u!4 &1483024674 stripped
|
||||||
|
Transform:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 1214567908930553594, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 1214567907777892293}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
--- !u!1 &1798297288
|
--- !u!1 &1798297288
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -397,6 +567,7 @@ GameObject:
|
|||||||
- component: {fileID: 1798297290}
|
- component: {fileID: 1798297290}
|
||||||
- component: {fileID: 1798297289}
|
- component: {fileID: 1798297289}
|
||||||
- component: {fileID: 1798297292}
|
- component: {fileID: 1798297292}
|
||||||
|
- component: {fileID: 1798297293}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Main Camera
|
m_Name: Main Camera
|
||||||
m_TagString: MainCamera
|
m_TagString: MainCamera
|
||||||
@ -502,6 +673,40 @@ MonoBehaviour:
|
|||||||
m_RequiresDepthTexture: 0
|
m_RequiresDepthTexture: 0
|
||||||
m_RequiresColorTexture: 0
|
m_RequiresColorTexture: 0
|
||||||
m_Version: 2
|
m_Version: 2
|
||||||
|
--- !u!114 &1798297293
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1798297288}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 72ece51f2901e7445ab60da3685d6b5f, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_ShowDebugText: 0
|
||||||
|
m_ShowCameraFrustum: 1
|
||||||
|
m_IgnoreTimeScale: 0
|
||||||
|
m_WorldUpOverride: {fileID: 0}
|
||||||
|
m_UpdateMethod: 2
|
||||||
|
m_BlendUpdateMethod: 1
|
||||||
|
m_DefaultBlend:
|
||||||
|
m_Style: 1
|
||||||
|
m_Time: 2
|
||||||
|
m_CustomCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve: []
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
m_CustomBlends: {fileID: 0}
|
||||||
|
m_CameraCutEvent:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_CameraActivatedEvent:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
--- !u!1 &1886541322
|
--- !u!1 &1886541322
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -712,6 +917,62 @@ PrefabInstance:
|
|||||||
m_Modification:
|
m_Modification:
|
||||||
m_TransformParent: {fileID: 0}
|
m_TransformParent: {fileID: 0}
|
||||||
m_Modifications:
|
m_Modifications:
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[0].m_PersistentCalls.m_Calls.Array.size
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[1].m_PersistentCalls.m_Calls.Array.size
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[0].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[1].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[0].m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 1483024672}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[1].m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 1483024672}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[0].m_PersistentCalls.m_Calls.Array.data[0].m_CallState
|
||||||
|
value: 2
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[1].m_PersistentCalls.m_Calls.Array.data[0].m_CallState
|
||||||
|
value: 2
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[0].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
||||||
|
value: OnMove
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[1].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
||||||
|
value: OnJump
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[0].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
||||||
|
value: PlayerMovement, Assembly-CSharp
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[1].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
||||||
|
value: PlayerMovement, Assembly-CSharp
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[0].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
|
||||||
|
value: UnityEngine.Object, UnityEngine
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[1].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
|
||||||
|
value: UnityEngine.Object, UnityEngine
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1214567908930553593, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553593, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
value: Vampire
|
value: Vampire
|
||||||
|
|||||||
1
Assets/Scripts/BaseState.cs
Normal file
1
Assets/Scripts/BaseState.cs
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
||||||
3
Assets/Scripts/BaseState.cs.meta
Normal file
3
Assets/Scripts/BaseState.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fadee52153f04fe39506c73e6e1613e4
|
||||||
|
timeCreated: 1648871987
|
||||||
@ -1,38 +1,88 @@
|
|||||||
|
#nullable enable
|
||||||
|
using JetBrains.Annotations;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.InputSystem;
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
[RequireComponent(typeof(PlayerInput), typeof(Rigidbody2D))]
|
[RequireComponent(typeof(PlayerInput), typeof(Rigidbody2D))]
|
||||||
public class PlayerMovement : MonoBehaviour {
|
public class PlayerMovement : MonoBehaviour {
|
||||||
[SerializeField] PlayerStats playerStats;
|
[SerializeField] PlayerStats playerStats;
|
||||||
Rigidbody2D rigidbody;
|
Rigidbody2D rb;
|
||||||
|
|
||||||
PlayerInput playerInput;
|
PlayerInput playerInput;
|
||||||
Vector2 moveDirection;
|
Vector2 moveDirection;
|
||||||
|
BaseState currentState = new NormalMovementState();
|
||||||
|
|
||||||
void Awake() {
|
void Awake() {
|
||||||
rigidbody = GetComponent<Rigidbody2D>();
|
rb = GetComponent<Rigidbody2D>();
|
||||||
playerInput = GetComponent<PlayerInput>();
|
playerInput = GetComponent<PlayerInput>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start() {
|
|
||||||
playerInput.actions["Move"].started += OnMove;
|
|
||||||
playerInput.actions["Move"].performed += OnMove;
|
|
||||||
playerInput.actions["Move"].canceled += OnMove;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnDestroy() {
|
|
||||||
playerInput.actions["Move"].started -= OnMove;
|
|
||||||
playerInput.actions["Move"].performed -= OnMove;
|
|
||||||
playerInput.actions["Move"].canceled -= OnMove;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FixedUpdate() {
|
void FixedUpdate() {
|
||||||
rigidbody.velocity = (Vector3)moveDirection * playerStats.movementSpeed;
|
if (currentState.FixedUpdateState(this) is {} newState)
|
||||||
|
SwitchState(newState);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnMove(InputAction.CallbackContext ctx) {
|
public void OnMove(InputAction.CallbackContext ctx) {
|
||||||
moveDirection = ctx.ReadValue<Vector2>();
|
moveDirection = ctx.ReadValue<Vector2>();
|
||||||
if (moveDirection.sqrMagnitude > 1.0f)
|
if (moveDirection.sqrMagnitude > 1.0f)
|
||||||
moveDirection.Normalize();
|
moveDirection.Normalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnJump(InputAction.CallbackContext ctx) {
|
||||||
|
if (!ctx.ReadValueAsButton())
|
||||||
|
return;
|
||||||
|
|
||||||
|
SwitchState(new JumpingMovementState());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SwitchState(BaseState newState) {
|
||||||
|
currentState.LeaveState(this);
|
||||||
|
currentState = newState;
|
||||||
|
newState.EnterState(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
class BaseState {
|
||||||
|
//TODO If we never do anything before enter, replace with constructor?
|
||||||
|
public virtual void EnterState(PlayerMovement playerMovement) {}
|
||||||
|
|
||||||
|
public virtual void LeaveState(PlayerMovement playerMovement) {}
|
||||||
|
|
||||||
|
[CanBeNull]
|
||||||
|
public virtual BaseState UpdateState(PlayerMovement playerMovement) => null;
|
||||||
|
|
||||||
|
[CanBeNull]
|
||||||
|
public virtual BaseState FixedUpdateState(PlayerMovement playerMovement) => null;
|
||||||
|
}
|
||||||
|
|
||||||
|
class NormalMovementState : BaseState {
|
||||||
|
public override BaseState FixedUpdateState(PlayerMovement playerMovement) {
|
||||||
|
playerMovement.rb.velocity = (Vector3)playerMovement.moveDirection * playerMovement.playerStats.movementSpeed;
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class JumpingMovementState : BaseState {
|
||||||
|
Vector3 startPosition;
|
||||||
|
float startTime;
|
||||||
|
|
||||||
|
public override void EnterState(PlayerMovement playerMovement) {
|
||||||
|
startPosition = playerMovement.transform.position;
|
||||||
|
startTime = Time.time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override BaseState FixedUpdateState(PlayerMovement playerMovement) {
|
||||||
|
float currentTime = Time.time - startTime;
|
||||||
|
if (currentTime >= playerMovement.playerStats.safeZoneJumpDuration)
|
||||||
|
return new NormalMovementState();
|
||||||
|
|
||||||
|
playerMovement.rb.MovePosition(Vector3.Lerp(
|
||||||
|
startPosition,
|
||||||
|
playerMovement.playerStats.safeZonePosition,
|
||||||
|
currentTime / playerMovement.playerStats.safeZoneJumpDuration
|
||||||
|
));
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -4,4 +4,8 @@
|
|||||||
public class PlayerStats : ScriptableObject {
|
public class PlayerStats : ScriptableObject {
|
||||||
public float movementSpeed = 3f;
|
public float movementSpeed = 3f;
|
||||||
public float suckSpeed = 1f;
|
public float suckSpeed = 1f;
|
||||||
|
|
||||||
|
//TODO Move to SafeZone scriptable object or in Stage/ArenaComponent?
|
||||||
|
public float safeZoneJumpDuration = 1.5f;
|
||||||
|
public Vector3 safeZonePosition;
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user