Clement Malaka Portfolio | Hades Recration

Hades Recreation

PLAY

The hades recreation was a group project I worked on with for school with some classmates. During creating this project I was responsible for the player's movement and combat system. The game was made in Unity and coded with C#. For a more indepth view of the game you can visit the github page HERE.

Game Thumbnail

Attack Combo

Here you can see the attack combo I have created for the player.

Combo display

Dash

I have created the dash, based on the snippet we got for our assignment. The dash can be used in both idle and walking state. When the player presses shift. In the code displayed in the slideshow you can see that I used a coroutine to handle the dash's cooldown. I made the cooldown speed and dash time serializable so it can be easily adjusted in the Unity editor.

Dash display
using System.Collections;
using UnityEngine;

public class Dash : MonoBehaviour
{
    public float dashSpeed;
    public float dashTime;
    public float dashingCooldown = 1f;

    bool inCooldown = false;

    public AudioSource dashAudioSource;

    private CharacterController Controller;

    private State UserStates;

    // Start is called before the first frame update
    void Start()
    {
        UserStates = GetComponent();
        Controller = GetComponent();
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            string state = UserStates.GetState();

            if (state == "Idle" || state == "Walking")
            {
                //dashAudioSource.Play();
                StartCoroutine(Fire());
            }
        }
    }

    IEnumerator Fire()
    {
        if (!inCooldown)
        {
            inCooldown = true;

            float startTime = Time.time;

            UserStates.ChangeState("Dashing");

            while (Time.time < startTime + dashTime)
            {
                // Calculate movement during the dash directly in this script
                Vector3 dashDirection = transform.forward;
                Controller.Move(dashDirection * dashSpeed * Time.deltaTime);

                yield return null;
            }

            UserStates.ChangeState("Idle");

            // Wait for the dash cooldown and enable dashing again
            yield return new WaitForSeconds(dashingCooldown);

            inCooldown = false;

            yield break;
        }
    }
}
                       
Dash code