# So im looking to rewrite this set of code

so have this code from online where I'm learning to limit this drone movement using this tutorial ("https://youtu.be/UghcAU0dsGI") so I'm trying to rewrite this just to make it shorter and easier to complete, but I don't get what clamping speed or magnitudes are, can someone help me understand what's going on in this code provided below and also tell me if there is an alternative to this, thanks

Code: private Vector3 velocityTosmoothdamptoZero; void ClampingSpeedValue() { if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.2f && Mathf.Abs(Input.GetAxis("Horizontal")) > 0.2f){ Drone.velocity = Vector3.ClampMagnitude(Drone.velocity, Mathf.Lerp(Drone.velocity.magnitude, 10.0f, Time.deltaTime * 5f)); }

```
if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.2f && Mathf.Abs(Input.GetAxis("Horizontal")) < 0.2f){
Drone.velocity = Vector3.ClampMagnitude(Drone.velocity, Mathf.Lerp(Drone.velocity.magnitude, 10.0f, Time.deltaTime * 5f));
}
if (Mathf.Abs(Input.GetAxis("Vertical")) < 0.2f && Mathf.Abs(Input.GetAxis("Horizontal")) > 0.2f){
Drone.velocity = Vector3.ClampMagnitude(Drone.velocity, Mathf.Lerp(Drone.velocity.magnitude, 5.0f, Time.deltaTime * 5f));
}
if (Mathf.Abs(Input.GetAxis("Vertical")) < 0.2f && Mathf.Abs(Input.GetAxis("Horizontal")) < 0.2f){
Drone.velocity = Vector3.SmoothDamp(Drone.velocity, Vector3.zero, ref velocityTosmoothdamptoZero, 0.95f);
}
}
```

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.