Help applying force in direction of an object

Hello, I am trying to get a dynamic object to accelerate towards another one (that is moving). What am I doing wrong here?

local imeda_position = go.get_position('imeda')

if imedadistance <= 800 then
		print('imeda: ', imeda_position)
		msg.post("#collisionobject1", "apply_force", {force = vmath.vector3(1, 1, 1), position = go.get_position('imeda')})
		label.set_text("#spaceship", "imeda")
		else

any help would be appreciated thank you

The force should be a vector pointing in the direction you wish to apply the force. Multiply it by some magnitude. Example:

-- apply force in direction of game object with id "to"
local from = go.get_position("from")
local to = go.get_position("to")
local direction = vmath.normalize(from - to)
local force = direction * 10000

msg.post("from#collisionobject", "apply_force", { force = force, position = from })
5 Likes

Thanks a lot, this really helped