diff --git a/3D blobici/Assets/Prefabs/PlayerContainer.prefab b/3D blobici/Assets/Prefabs/PlayerContainer.prefab index 784b80a..827c64a 100644 --- a/3D blobici/Assets/Prefabs/PlayerContainer.prefab +++ b/3D blobici/Assets/Prefabs/PlayerContainer.prefab @@ -14,7 +14,7 @@ GameObject: - component: {fileID: 1542319922315403782} - component: {fileID: 4745202387735708878} - component: {fileID: 7540455923916979795} - m_Layer: 0 + m_Layer: 6 m_Name: UI Canvas m_TagString: Untagged m_Icon: {fileID: 0} @@ -151,7 +151,7 @@ GameObject: - component: {fileID: 5692096231889078255} - component: {fileID: 4795552151069639100} - component: {fileID: 4576974581871443905} - m_Layer: 0 + m_Layer: 6 m_Name: HealthBig m_TagString: Untagged m_Icon: {fileID: 0} @@ -303,7 +303,7 @@ GameObject: - component: {fileID: 7664771988231841450} - component: {fileID: 1435586524702926551} - component: {fileID: 1075344197230042520} - m_Layer: 0 + m_Layer: 6 m_Name: Capsule m_TagString: Untagged m_Icon: {fileID: 0} @@ -388,7 +388,7 @@ GameObject: m_Component: - component: {fileID: 1831891111370080197} - component: {fileID: 495196005240376662} - m_Layer: 0 + m_Layer: 6 m_Name: Cards m_TagString: Untagged m_Icon: {fileID: 0} @@ -429,7 +429,7 @@ GameObject: - component: {fileID: 6559853192459065261} - component: {fileID: 8817225252079022943} - component: {fileID: 4603696628922152095} - m_Layer: 0 + m_Layer: 6 m_Name: HealtBar m_TagString: Untagged m_Icon: {fileID: 0} @@ -569,7 +569,7 @@ GameObject: - component: {fileID: 1781483820777133190} - component: {fileID: 8149587721611830724} - component: {fileID: 6867876445951065937} - m_Layer: 0 + m_Layer: 6 m_Name: Player m_TagString: Player m_Icon: {fileID: 0} @@ -681,7 +681,7 @@ GameObject: - component: {fileID: 3235429507807963288} - component: {fileID: 6461244435717521612} - component: {fileID: 6735253032573513453} - m_Layer: 0 + m_Layer: 6 m_Name: HealthBig m_TagString: Untagged m_Icon: {fileID: 0} @@ -755,7 +755,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 7001416999833331379} - m_Layer: 0 + m_Layer: 6 m_Name: PlayerContainer m_TagString: Untagged m_Icon: {fileID: 0} @@ -791,7 +791,7 @@ GameObject: - component: {fileID: 394159207937902131} - component: {fileID: 1316373350455901849} - component: {fileID: 4477917220216897301} - m_Layer: 0 + m_Layer: 6 m_Name: Camera m_TagString: MainCamera m_Icon: {fileID: 0} @@ -904,7 +904,7 @@ GameObject: - component: {fileID: 8991658504906099272} - component: {fileID: 7527513433228441835} - component: {fileID: 9201847439608863946} - m_Layer: 0 + m_Layer: 6 m_Name: ChestUIText m_TagString: Untagged m_Icon: {fileID: 0} diff --git a/3D blobici/Assets/Prefabs/enemy/Blob.prefab b/3D blobici/Assets/Prefabs/enemy/Blob.prefab index afea0f3..751a80c 100644 --- a/3D blobici/Assets/Prefabs/enemy/Blob.prefab +++ b/3D blobici/Assets/Prefabs/enemy/Blob.prefab @@ -14,7 +14,7 @@ GameObject: - component: {fileID: 8002523264253901019} - component: {fileID: 5415715946912615516} - component: {fileID: 146755941370531150} - m_Layer: 0 + m_Layer: 7 m_Name: Blob m_TagString: Enemy m_Icon: {fileID: 0} @@ -152,7 +152,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 4728640573077846392} - m_Layer: 0 + m_Layer: 7 m_Name: GroundCheck m_TagString: Untagged m_Icon: {fileID: 0} @@ -226,6 +226,14 @@ PrefabInstance: propertyPath: m_Name value: Blob_03 objectReference: {fileID: 0} + - target: {fileID: 919132149155446097, guid: 8dcf7567c8e945d429582464c51fe9eb, type: 3} + propertyPath: m_Layer + value: 7 + objectReference: {fileID: 0} + - target: {fileID: 8164078558771037576, guid: 8dcf7567c8e945d429582464c51fe9eb, type: 3} + propertyPath: m_Layer + value: 7 + objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] diff --git a/3D blobici/Assets/Scripts/Player/PlayerMovement.cs b/3D blobici/Assets/Scripts/Player/PlayerMovement.cs index c3f92a9..8e7c709 100644 --- a/3D blobici/Assets/Scripts/Player/PlayerMovement.cs +++ b/3D blobici/Assets/Scripts/Player/PlayerMovement.cs @@ -11,11 +11,14 @@ public class PlayerMovement : MonoBehaviour private CharacterController controller; private Vector3 velocity; + private Vector3 move; private PlayerSkillTree PlayerSkills; + private PlayerSkillHandler playerSkillHandler; private void Awake() { PlayerSkills = PlayerSkillTree.Instance; + playerSkillHandler = new PlayerSkillHandler(); } void Start() @@ -27,7 +30,13 @@ public class PlayerMovement : MonoBehaviour { if (Input.GetKeyDown(KeyCode.Space)) { - HandleDash(); + /* Ugly part here, need to rewrite later */ + float moveX = Input.GetAxisRaw("Horizontal"); + float moveZ = Input.GetAxisRaw("Vertical"); + /* End of the ugly part :P */ + + move = new Vector3(moveX, 0, moveZ).normalized; + StartCoroutine(playerSkillHandler.DashCoroutine(controller, move)); } if (Input.GetKeyDown(KeyCode.L)) @@ -45,6 +54,15 @@ public class PlayerMovement : MonoBehaviour void FixedUpdate() { + if (playerSkillHandler.IsDashing()) + { + Physics.IgnoreLayerCollision(6, 7, true); + } + else + { + Physics.IgnoreLayerCollision(6, 7, false); + } + HandleMovement(); ApplyGravity(); } @@ -53,7 +71,7 @@ public class PlayerMovement : MonoBehaviour { float moveX = Input.GetAxisRaw("Horizontal"); float moveZ = Input.GetAxisRaw("Vertical"); - Vector3 move = new Vector3(moveX, 0, moveZ).normalized; + move = new Vector3(moveX, 0, moveZ).normalized; if (move.magnitude >= 0.1f) { @@ -66,19 +84,6 @@ public class PlayerMovement : MonoBehaviour } } - void HandleDash() - { - if (PlayerSkills.IsSkillUnlocked(PlayerSkillTree.Skills.Dash)) - { - // Implement dash logic - Debug.Log("Dashing!"); - } - else - { - Debug.Log("Dash skill is not unlocked."); - } - } - void ApplyGravity() { if (IsGrounded() && velocity.y < 0) velocity.y = -2f; diff --git a/3D blobici/Assets/Scripts/Player/PlayerSkillHandler.cs b/3D blobici/Assets/Scripts/Player/PlayerSkillHandler.cs new file mode 100644 index 0000000..4fbe47a --- /dev/null +++ b/3D blobici/Assets/Scripts/Player/PlayerSkillHandler.cs @@ -0,0 +1,27 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PlayerSkillHandler +{ + private float dashSpeed = 15f; + private float dashDuration = 0.2f; + + private bool isDashing = false; + + public bool IsDashing() { return isDashing; } + + public IEnumerator DashCoroutine(CharacterController controller, Vector3 direction) + { + + float startTime = Time.time; + isDashing = true; + while (Time.time - startTime < dashDuration) + { + controller.Move(direction * dashSpeed * Time.deltaTime); + yield return null; + } + isDashing = false; + } + +} diff --git a/3D blobici/Assets/Scripts/Player/PlayerSkillHandler.cs.meta b/3D blobici/Assets/Scripts/Player/PlayerSkillHandler.cs.meta new file mode 100644 index 0000000..0b80da6 --- /dev/null +++ b/3D blobici/Assets/Scripts/Player/PlayerSkillHandler.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: bf963ec282f9eff40b50054039952aee \ No newline at end of file