Feat: Dash
Implemented basic dash logic WITHOUT cooldowns. Needs more changes down the line
This commit is contained in:
@@ -14,7 +14,7 @@ GameObject:
|
|||||||
- component: {fileID: 1542319922315403782}
|
- component: {fileID: 1542319922315403782}
|
||||||
- component: {fileID: 4745202387735708878}
|
- component: {fileID: 4745202387735708878}
|
||||||
- component: {fileID: 7540455923916979795}
|
- component: {fileID: 7540455923916979795}
|
||||||
m_Layer: 0
|
m_Layer: 6
|
||||||
m_Name: UI Canvas
|
m_Name: UI Canvas
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
@@ -151,7 +151,7 @@ GameObject:
|
|||||||
- component: {fileID: 5692096231889078255}
|
- component: {fileID: 5692096231889078255}
|
||||||
- component: {fileID: 4795552151069639100}
|
- component: {fileID: 4795552151069639100}
|
||||||
- component: {fileID: 4576974581871443905}
|
- component: {fileID: 4576974581871443905}
|
||||||
m_Layer: 0
|
m_Layer: 6
|
||||||
m_Name: HealthBig
|
m_Name: HealthBig
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
@@ -303,7 +303,7 @@ GameObject:
|
|||||||
- component: {fileID: 7664771988231841450}
|
- component: {fileID: 7664771988231841450}
|
||||||
- component: {fileID: 1435586524702926551}
|
- component: {fileID: 1435586524702926551}
|
||||||
- component: {fileID: 1075344197230042520}
|
- component: {fileID: 1075344197230042520}
|
||||||
m_Layer: 0
|
m_Layer: 6
|
||||||
m_Name: Capsule
|
m_Name: Capsule
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
@@ -388,7 +388,7 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 1831891111370080197}
|
- component: {fileID: 1831891111370080197}
|
||||||
- component: {fileID: 495196005240376662}
|
- component: {fileID: 495196005240376662}
|
||||||
m_Layer: 0
|
m_Layer: 6
|
||||||
m_Name: Cards
|
m_Name: Cards
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
@@ -429,7 +429,7 @@ GameObject:
|
|||||||
- component: {fileID: 6559853192459065261}
|
- component: {fileID: 6559853192459065261}
|
||||||
- component: {fileID: 8817225252079022943}
|
- component: {fileID: 8817225252079022943}
|
||||||
- component: {fileID: 4603696628922152095}
|
- component: {fileID: 4603696628922152095}
|
||||||
m_Layer: 0
|
m_Layer: 6
|
||||||
m_Name: HealtBar
|
m_Name: HealtBar
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
@@ -569,7 +569,7 @@ GameObject:
|
|||||||
- component: {fileID: 1781483820777133190}
|
- component: {fileID: 1781483820777133190}
|
||||||
- component: {fileID: 8149587721611830724}
|
- component: {fileID: 8149587721611830724}
|
||||||
- component: {fileID: 6867876445951065937}
|
- component: {fileID: 6867876445951065937}
|
||||||
m_Layer: 0
|
m_Layer: 6
|
||||||
m_Name: Player
|
m_Name: Player
|
||||||
m_TagString: Player
|
m_TagString: Player
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
@@ -681,7 +681,7 @@ GameObject:
|
|||||||
- component: {fileID: 3235429507807963288}
|
- component: {fileID: 3235429507807963288}
|
||||||
- component: {fileID: 6461244435717521612}
|
- component: {fileID: 6461244435717521612}
|
||||||
- component: {fileID: 6735253032573513453}
|
- component: {fileID: 6735253032573513453}
|
||||||
m_Layer: 0
|
m_Layer: 6
|
||||||
m_Name: HealthBig
|
m_Name: HealthBig
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
@@ -755,7 +755,7 @@ GameObject:
|
|||||||
serializedVersion: 6
|
serializedVersion: 6
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 7001416999833331379}
|
- component: {fileID: 7001416999833331379}
|
||||||
m_Layer: 0
|
m_Layer: 6
|
||||||
m_Name: PlayerContainer
|
m_Name: PlayerContainer
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
@@ -791,7 +791,7 @@ GameObject:
|
|||||||
- component: {fileID: 394159207937902131}
|
- component: {fileID: 394159207937902131}
|
||||||
- component: {fileID: 1316373350455901849}
|
- component: {fileID: 1316373350455901849}
|
||||||
- component: {fileID: 4477917220216897301}
|
- component: {fileID: 4477917220216897301}
|
||||||
m_Layer: 0
|
m_Layer: 6
|
||||||
m_Name: Camera
|
m_Name: Camera
|
||||||
m_TagString: MainCamera
|
m_TagString: MainCamera
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
@@ -904,7 +904,7 @@ GameObject:
|
|||||||
- component: {fileID: 8991658504906099272}
|
- component: {fileID: 8991658504906099272}
|
||||||
- component: {fileID: 7527513433228441835}
|
- component: {fileID: 7527513433228441835}
|
||||||
- component: {fileID: 9201847439608863946}
|
- component: {fileID: 9201847439608863946}
|
||||||
m_Layer: 0
|
m_Layer: 6
|
||||||
m_Name: ChestUIText
|
m_Name: ChestUIText
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ GameObject:
|
|||||||
- component: {fileID: 8002523264253901019}
|
- component: {fileID: 8002523264253901019}
|
||||||
- component: {fileID: 5415715946912615516}
|
- component: {fileID: 5415715946912615516}
|
||||||
- component: {fileID: 146755941370531150}
|
- component: {fileID: 146755941370531150}
|
||||||
m_Layer: 0
|
m_Layer: 7
|
||||||
m_Name: Blob
|
m_Name: Blob
|
||||||
m_TagString: Enemy
|
m_TagString: Enemy
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
@@ -152,7 +152,7 @@ GameObject:
|
|||||||
serializedVersion: 6
|
serializedVersion: 6
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 4728640573077846392}
|
- component: {fileID: 4728640573077846392}
|
||||||
m_Layer: 0
|
m_Layer: 7
|
||||||
m_Name: GroundCheck
|
m_Name: GroundCheck
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
@@ -226,6 +226,14 @@ PrefabInstance:
|
|||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
value: Blob_03
|
value: Blob_03
|
||||||
objectReference: {fileID: 0}
|
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_RemovedComponents: []
|
||||||
m_RemovedGameObjects: []
|
m_RemovedGameObjects: []
|
||||||
m_AddedGameObjects: []
|
m_AddedGameObjects: []
|
||||||
|
|||||||
@@ -11,11 +11,14 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
|
|
||||||
private CharacterController controller;
|
private CharacterController controller;
|
||||||
private Vector3 velocity;
|
private Vector3 velocity;
|
||||||
|
private Vector3 move;
|
||||||
private PlayerSkillTree PlayerSkills;
|
private PlayerSkillTree PlayerSkills;
|
||||||
|
private PlayerSkillHandler playerSkillHandler;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
PlayerSkills = PlayerSkillTree.Instance;
|
PlayerSkills = PlayerSkillTree.Instance;
|
||||||
|
playerSkillHandler = new PlayerSkillHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
@@ -27,7 +30,13 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
{
|
{
|
||||||
if (Input.GetKeyDown(KeyCode.Space))
|
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))
|
if (Input.GetKeyDown(KeyCode.L))
|
||||||
@@ -45,6 +54,15 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
|
|
||||||
void FixedUpdate()
|
void FixedUpdate()
|
||||||
{
|
{
|
||||||
|
if (playerSkillHandler.IsDashing())
|
||||||
|
{
|
||||||
|
Physics.IgnoreLayerCollision(6, 7, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Physics.IgnoreLayerCollision(6, 7, false);
|
||||||
|
}
|
||||||
|
|
||||||
HandleMovement();
|
HandleMovement();
|
||||||
ApplyGravity();
|
ApplyGravity();
|
||||||
}
|
}
|
||||||
@@ -53,7 +71,7 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
{
|
{
|
||||||
float moveX = Input.GetAxisRaw("Horizontal");
|
float moveX = Input.GetAxisRaw("Horizontal");
|
||||||
float moveZ = Input.GetAxisRaw("Vertical");
|
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)
|
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()
|
void ApplyGravity()
|
||||||
{
|
{
|
||||||
if (IsGrounded() && velocity.y < 0) velocity.y = -2f;
|
if (IsGrounded() && velocity.y < 0) velocity.y = -2f;
|
||||||
|
|||||||
27
3D blobici/Assets/Scripts/Player/PlayerSkillHandler.cs
Normal file
27
3D blobici/Assets/Scripts/Player/PlayerSkillHandler.cs
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bf963ec282f9eff40b50054039952aee
|
||||||
Reference in New Issue
Block a user