Make duble jump

This commit is contained in:
haitem 2021-01-30 14:55:08 +01:00
parent a6971e9669
commit d4e42d98eb
2 changed files with 218 additions and 125 deletions

View File

@ -1,5 +1,39 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &566066443751514267
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 905437667500735009}
- component: {fileID: 6840056971477016069}
- component: {fileID: 1945074935}
m_Layer: 0
m_Name: PlayerCube
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &905437667500735009
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 566066443751514267}
m_LocalRotation: {x: 0, y: -0.7071068, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0, y: -0.06, z: 0}
m_LocalScale: {x: 0.5, y: 0.5, z: 0.5}
m_Children:
- {fileID: 6549494719010083557}
- {fileID: 9047113762642319843}
m_Father: {fileID: 7094923891560833917}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: -90, z: 0}
--- !u!95 &6840056971477016069
Animator:
serializedVersion: 3
@ -31,6 +65,85 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d6a0240c7e91f1644908b3c8bb8d9c96, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &595899097229177098
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6549494719010083557}
- component: {fileID: 3409039630516751909}
- component: {fileID: 8685543899173780636}
m_Layer: 0
m_Name: Top
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6549494719010083557
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 595899097229177098}
m_LocalRotation: {x: -0.6703021, y: 0, z: 0, w: 0.74208844}
m_LocalPosition: {x: 0, y: 0.09190558, z: 0.018381115}
m_LocalScale: {x: 100, y: 100, z: 100}
m_Children: []
m_Father: {fileID: 905437667500735009}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &3409039630516751909
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 595899097229177098}
m_Mesh: {fileID: 8201437419870775723, guid: 79e5e296c19565d4ab4fc1de8b8d570f, type: 3}
--- !u!23 &8685543899173780636
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 595899097229177098}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 670224309865224971, guid: 79e5e296c19565d4ab4fc1de8b8d570f, type: 3}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!1 &7094923890942819438
GameObject:
m_ObjectHideFlags: 0
@ -185,8 +298,8 @@ GameObject:
m_Component:
- component: {fileID: 7094923891560833917}
- component: {fileID: 7094923891560833918}
- component: {fileID: 7094923891560833919}
- component: {fileID: 7094923891560833856}
- component: {fileID: 159011587373755370}
- component: {fileID: 6182518231170453917}
- component: {fileID: 7094923891560833916}
m_Layer: 0
m_Name: Player
@ -203,7 +316,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7094923891560833857}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0.5, z: 0}
m_LocalPosition: {x: 0, y: 0.500005, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 7094923890942819435}
@ -227,8 +340,8 @@ Rigidbody:
m_Interpolate: 0
m_Constraints: 120
m_CollisionDetection: 0
--- !u!65 &7094923891560833919
BoxCollider:
--- !u!136 &159011587373755370
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
@ -237,11 +350,12 @@ BoxCollider:
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!65 &7094923891560833856
BoxCollider:
m_Radius: 0.68
m_Height: 1
m_Direction: 1
m_Center: {x: 0, y: 0.18, z: 0}
--- !u!136 &6182518231170453917
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
@ -250,9 +364,10 @@ BoxCollider:
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 0.9, y: 0.8, z: 0.9}
m_Center: {x: 0, y: -0.2, z: 0}
m_Radius: 0.6
m_Height: 1
m_Direction: 1
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &7094923891560833916
MonoBehaviour:
m_ObjectHideFlags: 0
@ -270,116 +385,85 @@ MonoBehaviour:
mouseSensitive: 100
jump: 30
health: 100
actualHealth: 0
onGround: 0
--- !u!1001 &800087946616036810
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 7094923891560833917}
m_Modifications:
- target: {fileID: -8679921383154817045, guid: 79e5e296c19565d4ab4fc1de8b8d570f,
type: 3}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 79e5e296c19565d4ab4fc1de8b8d570f,
type: 3}
propertyPath: m_LocalScale.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 79e5e296c19565d4ab4fc1de8b8d570f,
type: 3}
propertyPath: m_LocalScale.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 79e5e296c19565d4ab4fc1de8b8d570f,
type: 3}
propertyPath: m_LocalScale.z
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 79e5e296c19565d4ab4fc1de8b8d570f,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 79e5e296c19565d4ab4fc1de8b8d570f,
type: 3}
propertyPath: m_LocalPosition.y
value: -0.06
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 79e5e296c19565d4ab4fc1de8b8d570f,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 79e5e296c19565d4ab4fc1de8b8d570f,
type: 3}
propertyPath: m_LocalRotation.w
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 79e5e296c19565d4ab4fc1de8b8d570f,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 79e5e296c19565d4ab4fc1de8b8d570f,
type: 3}
propertyPath: m_LocalRotation.y
value: -0.7071068
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 79e5e296c19565d4ab4fc1de8b8d570f,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 79e5e296c19565d4ab4fc1de8b8d570f,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 79e5e296c19565d4ab4fc1de8b8d570f,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: -90
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 79e5e296c19565d4ab4fc1de8b8d570f,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -677873421181713367, guid: 79e5e296c19565d4ab4fc1de8b8d570f,
type: 3}
propertyPath: m_LocalScale.x
value: 100
objectReference: {fileID: 0}
- target: {fileID: -677873421181713367, guid: 79e5e296c19565d4ab4fc1de8b8d570f,
type: 3}
propertyPath: m_LocalScale.y
value: 100
objectReference: {fileID: 0}
- target: {fileID: -677873421181713367, guid: 79e5e296c19565d4ab4fc1de8b8d570f,
type: 3}
propertyPath: m_LocalScale.z
value: 100
objectReference: {fileID: 0}
- target: {fileID: 919132149155446097, guid: 79e5e296c19565d4ab4fc1de8b8d570f,
type: 3}
propertyPath: m_Name
value: PlayerCube
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 79e5e296c19565d4ab4fc1de8b8d570f, type: 3}
--- !u!1 &566066443751514267 stripped
actualHealth: 100
onGround: 1
activeAbility:
--- !u!1 &8160361338157728753
GameObject:
m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: 79e5e296c19565d4ab4fc1de8b8d570f,
type: 3}
m_PrefabInstance: {fileID: 800087946616036810}
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
--- !u!4 &905437667500735009 stripped
serializedVersion: 6
m_Component:
- component: {fileID: 9047113762642319843}
- component: {fileID: 1891632148798472659}
- component: {fileID: 946952014299764603}
m_Layer: 0
m_Name: Top.001
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &9047113762642319843
Transform:
m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: 79e5e296c19565d4ab4fc1de8b8d570f,
type: 3}
m_PrefabInstance: {fileID: 800087946616036810}
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8160361338157728753}
m_LocalRotation: {x: -0.7069834, y: 0, z: 0, w: 0.7072302}
m_LocalPosition: {x: -0, y: 0, z: 0}
m_LocalScale: {x: 100, y: 100, z: 100}
m_Children: []
m_Father: {fileID: 905437667500735009}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &1891632148798472659
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8160361338157728753}
m_Mesh: {fileID: 4723784886265247870, guid: 79e5e296c19565d4ab4fc1de8b8d570f, type: 3}
--- !u!23 &946952014299764603
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8160361338157728753}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 670224309865224971, guid: 79e5e296c19565d4ab4fc1de8b8d570f, type: 3}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0

View File

@ -17,6 +17,9 @@ public class PlayerManager : MonoBehaviour
private Rigidbody rigidBody;
private PowerCubeManager powerCubeManager;
public List<int> activeAbility = new List<int>(); //without ability=0 or null, dubleJump = 1, push/pull = 2, dash = 3
private bool dubleJump = true;
private bool startEating = false;
private float saveSpeed;
@ -89,7 +92,7 @@ public class PlayerManager : MonoBehaviour
void Animation()
{
float localSpeed = 5f;
if (Input.GetAxis("Horizontal") > 0 && onGround)
if (Input.GetAxis("Horizontal") > 0)
{
playerAnimator.SetBool("Walk", true);
playerAnimator.transform.rotation = Quaternion.Lerp(
@ -98,7 +101,7 @@ public class PlayerManager : MonoBehaviour
localSpeed * Time.deltaTime
);
}
else if (Input.GetAxis("Horizontal") < 0 && onGround)
else if (Input.GetAxis("Horizontal") < 0)
{
playerAnimator.SetBool("Walk", true);
playerAnimator.transform.rotation = Quaternion.Lerp(
@ -127,13 +130,17 @@ public class PlayerManager : MonoBehaviour
{
if (Input.GetAxisRaw("Jump") > 0)
{
if (rigidBody.velocity.y <= 1 && onGround)
if (rigidBody.velocity.y <= 1 && (onGround || (dubleJump && activeAbility.Count > 0 && activeAbility[0] == 1)))
{
rigidBody.AddForce(
(transform.right * (run ? runSpeed : speed) * 5 * Input.GetAxis("Horizontal") * Time.deltaTime) +
(transform.up * jump * 10 * Time.deltaTime),
ForceMode.VelocityChange
);
if (!onGround)
{
dubleJump = false;
}
}
}
}
@ -210,6 +217,7 @@ public class PlayerManager : MonoBehaviour
{
rigidBody.MovePosition(transform.position);
onGround = true;
dubleJump = true;
}
}
@ -228,6 +236,7 @@ public class PlayerManager : MonoBehaviour
if (rigidBody.velocity.y <= 1 && !onGround) {
rigidBody.MovePosition(transform.position);
onGround = true;
dubleJump = true;
}
}
}