diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index b137a80..42bb903 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -1,5 +1,133 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!1 &2460619873126572304 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5260309551442468847} + - component: {fileID: 4810862233826936571} + m_Layer: 2 + m_Name: Trumpet + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5260309551442468847 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2460619873126572304} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: -0.227, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 5885597207104481986} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!82 &4810862233826936571 +AudioSource: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2460619873126572304} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 0} + m_audioClip: {fileID: 8300000, guid: 1a74d57acb3d84f25910c51cda225d81, type: 3} + m_PlayOnAwake: 0 + m_Volume: 1 + m_Pitch: 1 + Loop: 0 + Mute: 0 + Spatialize: 0 + SpatializePostEffects: 0 + Priority: 128 + DopplerLevel: 1 + MinDistance: 1 + MaxDistance: 500 + Pan2D: 0 + rolloffMode: 0 + BypassEffects: 0 + BypassListenerEffects: 0 + BypassReverbZones: 0 + rolloffCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + panLevelCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + spreadCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + reverbZoneMixCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 --- !u!1 &5885597207104481991 GameObject: m_ObjectHideFlags: 0 @@ -37,6 +165,7 @@ Transform: m_LocalScale: {x: 1.5, y: 1.5, z: 0.75} m_ConstrainProportionsScale: 1 m_Children: + - {fileID: 5260309551442468847} - {fileID: 5885597207531562994} - {fileID: 5885597208269163161} m_Father: {fileID: 0} @@ -255,8 +384,9 @@ MonoBehaviour: trumpet: 0 in_range: 0 enemy: {fileID: 0} - _groundCheckSize: {x: 0.52, y: 0.81} - _wallCheckSize: {x: 0.8, y: 0.97} + _groundCheckSize: {x: 0.22, y: 0.62} + _groundCheckOffset: 0.29 + _wallCheckSize: {x: 0, y: 0} _groundLayer: serializedVersion: 2 m_Bits: 64 diff --git a/Assets/SFX/TrumpetNote.wav b/Assets/SFX/TrumpetNote.wav new file mode 100644 index 0000000..80f8b6a Binary files /dev/null and b/Assets/SFX/TrumpetNote.wav differ diff --git a/Assets/SFX/TrumpetNote.wav.meta b/Assets/SFX/TrumpetNote.wav.meta new file mode 100644 index 0000000..155f91c --- /dev/null +++ b/Assets/SFX/TrumpetNote.wav.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 1a74d57acb3d84f25910c51cda225d81 +AudioImporter: + externalObjects: {} + serializedVersion: 7 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index dcf57e1..fc96d27 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -52,6 +52,7 @@ public class PlayerMovement : MonoBehaviour [Header("Checks")] //Size of groundCheck depends on the size of your character generally you want them slightly small than width (for ground) and height (for the wall check) [SerializeField] private Vector2 _groundCheckSize = new Vector2(0.49f, 0.03f); + [SerializeField] private float _groundCheckOffset; [Space(5)] [SerializeField] private Vector2 _wallCheckSize = new Vector2(0.5f, 1f); @@ -164,8 +165,10 @@ public class PlayerMovement : MonoBehaviour _isJumpCut = false; _isJumpFalling = false; Jump(); + if (!IsGrounded() && in_range && trumpet > 0) { + gameObject.transform.Find("Trumpet").GetComponent().Play(); enemy.GetComponent().DefeatEnemy(); enemy = null; in_range = false; @@ -174,6 +177,10 @@ public class PlayerMovement : MonoBehaviour { trumpet -= 1; } + // check if double jump, play sound + if (trumpet == 0) { + gameObject.transform.Find("Trumpet").GetComponent().Play(); + } } //WALL JUMP // else if (CanWallJump() && LastPressedJumpTime > 0) @@ -449,7 +456,7 @@ public class PlayerMovement : MonoBehaviour public bool IsGrounded() { // print(Physics2D.OverlapBox(this.transform.position, _groundCheckSize, 0, _groundLayer) && !IsJumping); - return (Physics2D.OverlapBox(this.transform.position, _groundCheckSize, 0, _groundLayer) && !IsJumping); + return (Physics2D.OverlapBox(new Vector2(this.transform.position.x, this.transform.position.y - _groundCheckOffset), _groundCheckSize, 0, _groundLayer) && !IsJumping); } #endregion @@ -458,7 +465,7 @@ public class PlayerMovement : MonoBehaviour private void OnDrawGizmosSelected() { Gizmos.color = Color.green; - Gizmos.DrawWireCube(this.transform.position, _groundCheckSize); + Gizmos.DrawWireCube(new Vector2(this.transform.position.x, this.transform.position.y - _groundCheckOffset), _groundCheckSize); Gizmos.color = Color.blue; Gizmos.DrawWireCube(this.transform.position, _wallCheckSize); Gizmos.DrawWireCube(this.transform.position, _wallCheckSize);