# Not satisfied with the speed control solution

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;

{
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);
``````
1 Like

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.