# Linear Damping towards one axis?

**URL:** <https://forums.unrealengine.com/t/linear-damping-towards-one-axis/385452>\
**Category:** World Creation\
**Tags:** Constraints, unreal-engine, Physics, question\
**Created:** [February 19, 2017, 8:04pm UTC](https://forums.unrealengine.com/t/linear-damping-towards-one-axis/385452 "2017-02-19T20:04:00Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![BenVlodgi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/benvlodgi/32/1194567_2.png) [@BenVlodgi](https://forums.unrealengine.com/u/BenVlodgi)\
**Post date:** [May 16, 2019, 7:15pm UTC](https://forums.unrealengine.com/t/linear-damping-towards-one-axis/385452/3 "2019-05-16T19:15:48Z")

</div>

The code that handles LinearDamping is here  
[DyBodyCoreIntegrator.h | bodyCoreComputeUnconstrainedVelocity](https://github.com/EpicGames/UnrealEngine/blob/70bc980c6361d9a7d23f6d23ffe322a2d6ef16fb/Engine/Source/ThirdParty/PhysX3/PhysX_3.4/Source/LowLevelDynamics/src/DyBodyCoreIntegrator.h#L72)

I’ve re-written it a bit to be easier to read

```
Vector3 linearVelocity
float linearDamping
float deltaSeconds

float linearDampingTimesDeltaSeconds = linearDamping * deltaSeconds
float linearVelocityMultiplier = Max(0.0f, 1.0f - linearDampingTimesDeltaSeconds)
linearVelocity *= linearVelocityMultiplier

```

This uses a single float to reduce velocity in all directions. To solve your problem, there’s a few options.

**Solution 1** : You could apply less force when moving the object around based on the velocity direction.

**Solution 2** : For moving objects around I recommend using the [PhysicsHandle](https://api.unrealengine.com/INT/BlueprintAPI/Physics/Components/PhysicsHandle/index.html), use this instead of a impulses. After grabbing a component, you can move the target location more or less based on direction.

- [UPhysicsHandleComponent](https://api.unrealengine.com/INT/API/Runtime/Engine/PhysicsEngine/UPhysicsHandleComponent/index.html)

**Solution 3** : You can put this code into a component or actor, that runs this logic every tick (probably want it `post physics tick`). You would get the `LinearVelocity` from the physics component, run this math. Then set the new `LinearVelocity`. You would then not set the physics component’s actual linear dampening, and just set it here. The only difference, is that here we use a vector for each axis of velocity damping.

```
Vector3 linearVelocity
Vector3 linearDamping
float deltaSeconds

Vector3 linearDampingTimesDeltaSeconds = linearDamping * deltaSeconds
Vector3 linearVelocityMultiplier = Vector3(
    Max(0.0f, 1.0f - linearDampingTimesDeltaSeconds.X),
    Max(0.0f, 1.0f - linearDampingTimesDeltaSeconds.Y),
    Max(0.0f, 1.0f - linearDampingTimesDeltaSeconds.Z))
linearVelocity *= linearVelocityMultiplier

```

---

_[View the full topic](https://forums.unrealengine.com/t/linear-damping-towards-one-axis/385452)._
