object to point.

Lets say I have 3 props, and I want them to all to move to a certain point in space.

I found this:

Only I need some math lessons on how to do this…

You don’t. Look:

ApplyForceCenter makes an entity move without torque.
ApplyForceOffset makes an entity move with torque.

ApplyForceCenter is the like ApplyForceOffset(ent:GetCenter()) (or whatever).

You need to make ApplyForceCenter(point) on all entities you want.

You want to get the vector between the entity you want to move and the point you want to move it to, then apply force along that vector.

[lua]local phys = ent:GetPhysicsObject()
if ValidEntity(phys) then
local vec = point - ent:GetPos()
phys:ApplyForceCenter(vec)
end[/lua]

[editline]07:03PM[/editline]

You can multiply vec by a number to increase the force applied.

I understand that and I do only need the math lessons.

[editline]08:06PM[/editline]

Thanks, its awesome how easy vectors are sometimes.

[editline]08:09PM[/editline]

Since you’re here, how would you get the objects to the point ? I have the entity’s(metatables ?) stored in a table.

Specify more clearly what you want to do. Do you need a way to get the entities that have to move to the point? If so, what is the criteria?

I have a swep, that selects multiple entities and stores them into a table, then I want all the props to move to a certain point in space. I was thinking on doing something like :

pseudocode :
[lua]
for k,v in pairs(ents)
v.think = function ()
gotopoint code here.
end
end
[/lua]

That would be doing it inside-out.

[lua]function SWEP:Think()
for _, v in ipairs(ents) do – Just warning you that naming your table ents will override the ents library.
– Apply force to v here.
end
end[/lua]

It was pseudocode, my actual code contains something like Entitys but thanks anyway