So if we take 0 dmg while we can hold the blocking button forever. Isn’t this like cheating GOD MODE turned on?
Even as you said in a video someone can attack from the side but still even that it’s easy to abuse just pull one or stand in the place where they can attack you from one direction.
That’s why the stamina system should be good here so you lose at least stamina while blocking. So you cannot block forever.
Or if we can put a timer on the button how long we can hold it? Like a 1.5sek max holding button.
Would be nice if we get an update on the blocking system.
You can block forever. But do you want to? No point in a game where you just stand and block for 2 hours. At some point you are going to have to attack.
But your point is valid. I actually implemented a stamina system in my own project.
As alternate to the stamine system, maybe the enemy can break through if you only stand there to block the attacks?
My solution was a bit more evil/fair…
In my game blocking reduces damage but does not drop it to zero. Regular weapon damage for me is a range from .8 to 1.2 times damage. Blocked weapon damage is a range from 0 to .5 times damage.
In other words, I’d advise you not to just stand there and get hit.
I’ve seen this in games and the thought of implementing it crossed my mind. Blocking doesn’t negate all damage, but reduces it to, say, 10% of what it originally would’ve been.
Strong attacks that can break through blocks and stun the blocker is a good option, too. With the state machine it would be quite simple to implement a stunned state. The enemy AI simply count how many consecutive attacks were blocked and switch to this strong attack after x. Or some more complicated fighting AI, but this is where I would start. Perhaps a progressive probability. 1 blocked attack? 10% chance of doing a strong attack next. 2 blocked attacks? 20% chance of switching, etc. You don’t even need a stun. A broken block would just prevent you from blocking again for 1 second or so. Then follow-up attacks will get through. Perhaps, instead of a strong attack, each attack just have a small percentage chance of being critical, dealing 2x damage normally, or breaking through a blocked attack.
The options are almost endless
Or you could stagger after too many hits and maybe fall down. Then youre an easy target in the time you have to get up again. ^^
public void ReduceDamageTaken(bool reduceDamage)
{
this.reduceDamage = reduceDamage;
}
public void DealDamage(float damage)
{
if (currentHealth <= 0) { return; }
if (reduceDamage)
{
decreaseDamage = damage - (damage * 1.2f);
currentHealth -= decreaseDamage;
}
currentHealth = Mathf.Max(currentHealth - damage, 0);
//event
OnTakeDamage?.Invoke();
if (currentHealth == 0)
{
OnDeath?.Invoke();
}
Debug.Log(currentHealth);
}
I went with 20 % reduced damage. It looks good. I will have an upgrade system so I will let player upgrade that part if he wants so he can reduce more dmg. Will just upgrade the defense formula later.
I just need to figure out why I am still going into get-hit animation when I am blocking. Why I am not in block animation always. And yes I set block animation on loop.
I don’t have the codebase here at work, but a place to start is to look at where the change of state to a hit state is called. For example, we switch some states in PlayerStateMachine…
We have an event handler on the player state machine that switches to the PlayerImpactState
whenever we take damage. I guess you could pass the amount of damage (and type of damage) through and only switch the state if it exceeds a certain threshold
Orr simply check InputReader.IsBlocking…