# Smooth motion for an entity?

Hello, I have a body which, is capable of performing a smooth, not the typical “1 to 10”, which is more accurate “1.1 to 1.2 …”
Similar to position, movement and speed

From already thank you very much, by the way, I try to use

[Lua]
function ENT:Think()

``````Pos = self.Entity:GetPos()

Pos.x = Pos.x + math.sin(CurTime()) * math.random(-5, 5)
Pos.y = Pos.y + math.cos(CurTime()) * math.random(-5, 5)
Pos.z = Pos.z + math.cos(CurTime()) * math.random(-5, 5)

local Angle = Pos - self.Entity:GetPos()
local Distance = Angle:Length()
local PhysObj = self.Entity:GetPhysicsObject()
local Velocity = PhysObj:GetVelocity()

self.Entity:SetPos(Pos)
self.Entity:SetAngles(Angle)
self.Entity:SetVelocity(Velocity)
``````

end
[/lua]

But only with a robust movement of poor quality
So this does not help me at all …

also self.Entity == self so its kinda redundant.

the Think hook is called every 0.19 seconds, so you are trying to move it every 0.19 seconds which might be causing lag?

at the bottom of your think hook try using something like [lua]self:NextThink(1) [/lua] which will make the think hook be called every second instead of every 0.19 seconds.

You can use LerpVector and LerpAngle to smoothen it out. Also, self.Entity is the equivalent of self.