fade when dashing

master
Jordan Orelli 4 years ago
parent bfd71459be
commit b9d8c233d6

@ -9,7 +9,7 @@ Material:
m_PrefabAsset: {fileID: 0}
m_Name: Player
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
@ -62,13 +62,13 @@ Material:
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _GlossyReflections: 0
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SpecularHighlights: 0
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1

@ -13,7 +13,7 @@ GameObject:
- component: {fileID: 70526350792130533}
- component: {fileID: 7913819140294386521}
m_Layer: 8
m_Name: DashIndicator
m_Name: Right Dash Indicator
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -127,6 +127,7 @@ Transform:
m_LocalScale: {x: 1, y: 2, z: 1}
m_Children:
- {fileID: 651885954300002501}
- {fileID: 6104415401532622193}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -158,55 +159,8 @@ MonoBehaviour:
maxJumps: 2
tracerPrefab: {fileID: 2438817463505096557, guid: 76ce4ec4aba832343abb5a3c19e66b7c,
type: 3}
dashIndicator: {fileID: 3504191955490326659}
moveAction:
m_Name: Move
m_Type: 0
m_ExpectedControlType:
m_Id: ad4acdfe-fdb1-4bba-aaee-fd23b58c9e76
m_Processors:
m_Interactions:
m_SingletonActionBindings:
- m_Name:
m_Id: a136d531-716d-40df-bf2c-d970a579bfb2
m_Path: <Gamepad>/leftStick
m_Interactions:
m_Processors:
m_Groups:
m_Action: Move
m_Flags: 0
jumpAction:
m_Name: Jump
m_Type: 0
m_ExpectedControlType:
m_Id: 90cb081e-cdb8-497b-bbf1-8731dc964572
m_Processors:
m_Interactions:
m_SingletonActionBindings:
- m_Name:
m_Id: 49bfcfda-05b6-4d6d-acef-7105797c2c76
m_Path: <Gamepad>/buttonSouth
m_Interactions:
m_Processors:
m_Groups:
m_Action: Jump
m_Flags: 0
dashAction:
m_Name: Dash
m_Type: 0
m_ExpectedControlType:
m_Id: 3a2b1052-20a3-4b83-ad55-3b4df6265ed0
m_Processors:
m_Interactions:
m_SingletonActionBindings:
- m_Name:
m_Id: 26ac24c7-89f8-431a-a81a-14dff12d2862
m_Path: <Gamepad>/buttonWest
m_Interactions:
m_Processors:
m_Groups:
m_Action: Dash
m_Flags: 0
leftDashIndicator: {fileID: 4630466111644168105}
rightDashIndicator: {fileID: 3504191955490326659}
jumpState: 0
jumpDirection: 0
jumpCount: 0
@ -301,3 +255,97 @@ BoxCollider2D:
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_EdgeRadius: 0
--- !u!1 &4630466111644168105
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6104415401532622193}
- component: {fileID: 4941177478372744224}
- component: {fileID: 6854640812885047320}
- component: {fileID: 3071215866828230560}
m_Layer: 8
m_Name: Left Dash Indicator
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!4 &6104415401532622193
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4630466111644168105}
m_LocalRotation: {x: 0, y: 0, z: -0.38268343, w: 0.92387956}
m_LocalPosition: {x: -0.5, y: 0, z: 0}
m_LocalScale: {x: 0.5, y: 0.5, z: 0.5}
m_Children: []
m_Father: {fileID: 4623847142764859880}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: -45}
--- !u!33 &4941177478372744224
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4630466111644168105}
m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &6854640812885047320
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4630466111644168105}
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: 10303, guid: 0000000000000000f000000000000000, type: 0}
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!64 &3071215866828230560
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4630466111644168105}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 3
m_Convex: 0
m_CookingOptions: 30
m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}

@ -23,7 +23,8 @@ public class PlayerController : MonoBehaviour {
public float coyoteTime = 0.1f;
public int maxJumps = 2;
public GameObject tracerPrefab;
public GameObject dashIndicator;
public GameObject leftDashIndicator;
public GameObject rightDashIndicator;
public PlayerControls controls;
@ -416,12 +417,30 @@ public class PlayerController : MonoBehaviour {
velocity.y = 0;
lastDashTime = Time.time;
setJumpState(JumpState.Dash);
StartCoroutine(dashFade());
return true;
}
public IEnumerator dashFade() {
Material m = gameObject.GetComponent<MeshRenderer>().materials[0];
float dt = 0;
float h = 0;
float s = 0;
float v = 0;
Color.RGBToHSV(m.color, out h, out s, out v);
float maxSaturation = s;
while (dt < dashCooldown) {
s = Mathf.Clamp(dt / dashCooldown, 0f, maxSaturation);
m.color = Color.HSVToRGB(h, s, v);
dt += Time.deltaTime;
yield return true;
}
}
void setJumpState(JumpState state) {
dashIndicator.SetActive(state == JumpState.Dash);
leftDashIndicator.SetActive(state == JumpState.Dash && velocity.x < 0);
rightDashIndicator.SetActive(state == JumpState.Dash && velocity.x >= 0);
if (jumpState != JumpState.Ascending && state == JumpState.Ascending) {
jumpStartTime = Time.time;
}

Loading…
Cancel
Save