Skip to content

Commit

Permalink
Adds enraged logic and shader for visuals
Browse files Browse the repository at this point in the history
Adds a script to "enrage" the mad mantis in the animator and a shader manager to control the values and states, as well as a shader graph to color it gradually red and make it wavy during the enraging animation.
Adds the URP package to enable using shadergraph with sprites.
  • Loading branch information
LeonardoTPereira committed Feb 3, 2023
1 parent 77c7c95 commit 46681e9
Show file tree
Hide file tree
Showing 30 changed files with 11,112 additions and 6,852 deletions.
26 changes: 24 additions & 2 deletions Assets/Animators/MadMantis.controller
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ AnimatorState:
m_CycleOffset: 0
m_Transitions:
- {fileID: 2881879935408135944}
m_StateMachineBehaviours: []
m_StateMachineBehaviours:
- {fileID: -2950604801573636325}
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
Expand All @@ -264,6 +265,18 @@ AnimatorState:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!114 &-2950604801573636325
MonoBehaviour:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e535c5094ff59764991713eaaddf3987, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1101 &-2709564222167594883
AnimatorStateTransition:
m_ObjectHideFlags: 1
Expand Down Expand Up @@ -421,6 +434,12 @@ AnimatorController:
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
- m_Name: FinishedRage
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
Expand Down Expand Up @@ -533,7 +552,10 @@ AnimatorStateTransition:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: FinishedRage
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -1456754165148399937}
m_Solo: 0
Expand Down
62 changes: 62 additions & 0 deletions Assets/Materials/MadMantisMaterial.mat
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: MadMantisMaterial
m_Shader: {fileID: -6465566751694194690, guid: ef1a2e5dd02533043affa83176d81b67, type: 3}
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _AlphaTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 8620bcf7fa769e94fa548c2fc0325ef4, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MaskTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _NormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _BUILTIN_QueueControl: -1
- _BUILTIN_QueueOffset: 0
- _EnableExternalAlpha: 0
- _FillRate: 0
- _IsEnraging: 0
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Flip: {r: 1, g: 1, b: 1, a: 1}
- _RendererColor: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []
8 changes: 8 additions & 0 deletions Assets/Materials/MadMantisMaterial.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 81 additions & 2 deletions Assets/Scenes/TestScenes/Boss.unity
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ GameObject:
- component: {fileID: 1101176998}
- component: {fileID: 1101176997}
- component: {fileID: 1101176996}
- component: {fileID: 1101176999}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
Expand Down Expand Up @@ -207,6 +208,39 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1101176999
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1101176995}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_RenderShadows: 1
m_RequiresDepthTextureOption: 2
m_RequiresOpaqueTextureOption: 2
m_CameraType: 0
m_Cameras: []
m_RendererIndex: -1
m_VolumeLayerMask:
serializedVersion: 2
m_Bits: 1
m_VolumeTrigger: {fileID: 0}
m_VolumeFrameworkUpdateModeOption: 2
m_RenderPostProcessing: 0
m_Antialiasing: 0
m_AntialiasingQuality: 2
m_StopNaN: 0
m_Dithering: 0
m_ClearDepth: 1
m_AllowXRRendering: 1
m_RequiresDepthTexture: 0
m_RequiresColorTexture: 0
m_Version: 2
--- !u!1001 &2000874186053806221
PrefabInstance:
m_ObjectHideFlags: 0
Expand All @@ -230,21 +264,49 @@ PrefabInstance:
propertyPath: m_Name
value: MadMantis
objectReference: {fileID: 0}
- target: {fileID: 2000874187470131646, guid: 8c23382576d5628428f73b2aab619294, type: 3}
propertyPath: m_Size.x
value: 4.36
objectReference: {fileID: 0}
- target: {fileID: 2000874187470131646, guid: 8c23382576d5628428f73b2aab619294, type: 3}
propertyPath: m_Size.y
value: 7.38
objectReference: {fileID: 0}
- target: {fileID: 2000874187470131646, guid: 8c23382576d5628428f73b2aab619294, type: 3}
propertyPath: m_Sprite
value:
objectReference: {fileID: 21300000, guid: 1031ce43a49298e42ac2e377f06bb00e, type: 3}
- target: {fileID: 2000874187470131646, guid: 8c23382576d5628428f73b2aab619294, type: 3}
propertyPath: m_WasSpriteAssigned
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2000874187470131646, guid: 8c23382576d5628428f73b2aab619294, type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: d8b65391adb5d5740a57742c73a04869, type: 2}
- target: {fileID: 2000874187470131647, guid: 8c23382576d5628428f73b2aab619294, type: 3}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2000874187470131647, guid: 8c23382576d5628428f73b2aab619294, type: 3}
propertyPath: m_LocalScale.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 2000874187470131647, guid: 8c23382576d5628428f73b2aab619294, type: 3}
propertyPath: m_LocalScale.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 2000874187470131647, guid: 8c23382576d5628428f73b2aab619294, type: 3}
propertyPath: m_LocalPosition.x
value: 4.97
objectReference: {fileID: 0}
- target: {fileID: 2000874187470131647, guid: 8c23382576d5628428f73b2aab619294, type: 3}
propertyPath: m_LocalPosition.y
value: -1.77
value: -1.76
objectReference: {fileID: 0}
- target: {fileID: 2000874187470131647, guid: 8c23382576d5628428f73b2aab619294, type: 3}
propertyPath: m_LocalPosition.z
value: -0.00002823677
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2000874187470131647, guid: 8c23382576d5628428f73b2aab619294, type: 3}
propertyPath: m_LocalRotation.w
Expand Down Expand Up @@ -276,3 +338,20 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 8c23382576d5628428f73b2aab619294, type: 3}
--- !u!1 &2000874186053806222 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 2000874187470131645, guid: 8c23382576d5628428f73b2aab619294, type: 3}
m_PrefabInstance: {fileID: 2000874186053806221}
m_PrefabAsset: {fileID: 0}
--- !u!114 &2000874186053806223
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2000874186053806222}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b6aeba9d40646d44797b8c15fa3de4c0, type: 3}
m_Name:
m_EditorClassIdentifier:
11 changes: 11 additions & 0 deletions Assets/Scripts/Bosses/MadMantisEnrage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MadMantisEnrage : StateMachineBehaviour
{
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
animator.GetComponent<MadMantisShaderManager>().Enrage();
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Bosses/MadMantisEnrage.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions Assets/Scripts/Bosses/MadMantisShaderManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class MadMantisShaderManager : MonoBehaviour
{
private float _fillRate;
private float _step;
private Material _material;
private Animator _animator;

private void Awake()
{
_fillRate = 0f;
_step = 0.05f;
_material = GetComponent<Renderer>().material;
_animator = GetComponent<Animator>();
}

public void Enrage()
{
_material.SetFloat("_IsEnraging", 1);
StartCoroutine(FillRage());
}

private IEnumerator FillRage()
{
while (_fillRate < 1.0f)
{
_material.SetFloat("_FillRate", _fillRate);
_fillRate += _step;
yield return new WaitForSeconds(2 * _step);
}
_animator.SetTrigger("FinishedRage");
_material.SetFloat("_IsEnraging", 0);
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Bosses/MadMantisShaderManager.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Shaders.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 46681e9

Please sign in to comment.