Skip to content
Snippets Groups Projects
Commit b0584934 authored by Robin Halseth Sandvik's avatar Robin Halseth Sandvik
Browse files

Small fix to charging mechanic.

- Can only start charging if ability is ready.
- Can only release if it is actually charging.
parent f0c53827
No related branches found
No related tags found
Loading
......@@ -212,19 +212,22 @@ namespace BigSock {
// Charge: Fire when let go.
case FireType.Charge:
// If pressed down: Store start time.
if (Input.GetKeyDown(key)) {
ability.ChargeStarted = Time.time;
if(Input.GetKeyDown(key)) {
// Only start charging if the ability is ready.
if(ability.Ability.Ready) ability.ChargeStarted = Time.time;
return true;
}
// If let go: Activate
else if (Input.GetKeyUp(key)) {
par.ChargeTime = ability.ChargeTime;
var t = ability.Ability.Use(par);
if (!t) {
if (par.ChargeTime < ability.Ability.MinCharge)
Debug.Log($"[PlayerController.CheckAbilityInput({key})] {ability.Ability.Name} not fired ({par.ChargeTime:N3} < {ability.Ability.MinCharge:N3})");
else if(Input.GetKeyUp(key)) {
if(ability.IsCharging) {
par.ChargeTime = ability.ChargeTime;
var t = ability.Ability.Use(par);
if (!t) {
if (par.ChargeTime < ability.Ability.MinCharge)
Debug.Log($"[PlayerController.CheckAbilityInput({key})] {ability.Ability.Name} not fired ({par.ChargeTime:N3} < {ability.Ability.MinCharge:N3})");
}
ability.ChargeStarted = 0f; // Reset charge time when we release the key.
}
ability.ChargeStarted = 0f; // Reset charge time when we release the key.
return true;
}
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment