Im trying to get a character to move but when i run the engine it doesnt work what am i doing wrong please?
function init(self)
msg.post(".","acquire_input_focus")
end
function final(self)
end
function update(self, dt)
end
function on_message(self, message_id, message, sender)
end
function on_input(self, action_id, action)
if action_id == hash('action') and action.pressed then
print('o')
msg.post(".", "apply_force", {force = vmath.vector3(10, 0, 0), position = go.get_position()})
end
end
function on_reload(self)
end
Can you see the “o” in the console log when you press the action? If so, then it is working, but at any rate your force is way too small to be noticeable. Try a force of 1000 or 10000. The “apply_force” message will only apply that force for one frame.
1 Like
Also, check your input settings
Maybe you forgot to add some button to action hash actually.
1 Like
yeah i see the “o” ill increase the force
i tried increasing the force but didnt work
It’s hard to give any pointers without knowing more about your game setup. Do you have a collision object attached to the game object you are applying force to?
If you like you can invite me to the project and I can have a look, johan.beck-noren[at]king.com
/Johan
thanks for your concern i used go.animate and it worked
The “apply_force” message is only for collision object components with their type set to “dynamic” (simulated rigid bodies). It’s the only way to interact with them, and it doesn’t work for any other type of collision object or any other component or game object. To move normal things around you use go.set_position() or go.animate().