# How CurrentForwardSpeed Works?

**URL:** <https://forums.unrealengine.com/t/how-currentforwardspeed-works/309858>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [March 7, 2015, 9:46pm UTC](https://forums.unrealengine.com/t/how-currentforwardspeed-works/309858 "2015-03-07T21:46:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Snipe3000](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Snipe3000](https://forums.unrealengine.com/u/Snipe3000)\
**Post date:** [March 7, 2015, 9:46pm UTC](https://forums.unrealengine.com/t/how-currentforwardspeed-works/309858/1 "2015-03-07T21:46:21Z")

</div>

I think this will be a simple question for most of you.  
I’m looking at the C++ Flying template, and inside of the pawn code I see code like this:

```
CurrentForwardSpeed = FMath::Clamp(NewForwardSpeed, MinSpeed, MaxSpeed);

```

I think I’m missing the basics of how the code is structured. Is CurrentForwardSpeed a built in variable of the Actor class that’s being overwritten? is that how the engine knows what the new Forward speed is?

The reason I’m asking is because I’m just trying to do simple manipulations such as, add vertical and horizontal thrusts.

---

<div class="post-metadata">

**Author:** ![Leirith](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Leirith](https://forums.unrealengine.com/u/Leirith)\
**Post date:** [December 20, 2016, 10:41pm UTC](https://forums.unrealengine.com/t/how-currentforwardspeed-works/309858/2 "2016-12-20T22:41:34Z")

</div>

`CurrentForwardSpeed` is not built in, but rather defined by the particular subclass of `APawn` you’re viewing currently. Every `Tick`, it is used to calculate an `FVector` identified as `LocalMove` that is passed to `AddActorLocalOffset` (which is a built-in method of `AActor`). That will then cause the engine to move the pawn at its current speed.

The `FMath::Clamp` function you referenced is used to set upper and lower bounds on the current speed, i.e. so the pawn can’t move any faster or slower than `MaxSpeed` and `MinSpeed` respectively.
