Hi there,
once again, I want to talk about the speed control solution that is exposed in the lecture.
Having a patrolFraction speed is ok for me.
ALso, having the player always going at full speed seems ok (at least it is quite easy to change if we want the status of the player - ill, frozen or injuried- impact his speed).
But I really disagree with putting 1f when we call the move method in the fighter module. What if any status (as mentionned before) is increasing / decreasing the speed? We’ll have an injuried enemy that is walking at half speed an, suddenly, getting back at full speed when he fights? It doesn’t feel good to me.
What would be a good solution? Passing a speedFraction parameter to the fighter method from the controller?
Doesn’t sound great to me. The fighter module should take care of fighting, not moving…
Can’t figure out the best solution. Any advice?
Thanks!
After scratching my head a little bit, I come with this solution.
I’ll have the controller (AI’s or player’s) handle the percentage speed, regarding the behaviour and or the status.
Then, the controller will pass the speed percentage to the mover (using a new method like SetSpeed).
At last, the mover’s script will internally use this percentage speed to apply it to the maxSpeed.
Is it a valid approach?
Bonus question: what if I want to have my status / behaviour (I’m thinking at chilled / frozen right now) also impact my attack speed?
We actually don’t cover these status in the course at this time.
I would have a property in Mover that covers effects by status ailment… For example, if an effect causes the character’s speed to be reduced (say, chilled reduces movement speed by 50%, then -.5f is added to the movement modifier…
float effectModifer = 1.0f;
public void AddEffect(float amount)
{
effect+=amount;
}
When chilled,
GetComponent<Mover>().AddEffect(-.5f);
When thawed,
GetComponent<Mover>().RemoveEffect(.5f);
When moving,
navMeshAgent.speed = maxSpeed * Mathf.Clamp01(speedFraction) * Mathf.Clamp01(effectModifier);
Thank you Brian.
Maybe you’ll cover status in this course too one day
Thank you for the great job at GameDev!
I really enjoy the quality of the lectures and can’t wait to discover the other parts (inventory, quests and so…)!
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.