an object that spawns objects (using a factory) with static collision on mouse click.
another object with a script that turns gravity back on when I press space (gravity is disabled in init).
an object with dynamic collision
When I start the game, the object stays in the air until I press space. Then it falls normally, but if I have spawned some of the static collision object before I press space, the object does not fall. Any ideas?
Here is how I turn on gravity: physics.set_gravity(vmath.vector3(0.0, -2000.0, 0.0))
I created a very small project that reproduced the issue. But it seems the problem is not with spawning a static object but with generating any input.
If I move the mouse or press any key before pressing space, the object will not fall. If I keep my hand out of the mouse and keyboard until I press space, the object falls.
If you still want the project I can send it. Should I zip it and attach it here?
I feel there is no need for a project. With this code and a dynamic object in the scene it is enough:
function init(self)
msg.post("#", "acquire_input_focus")
physics.set_gravity(vmath.vector3(0.0, 0.0, 0.0))
print("gravity disabled on init")
end
function on_input(self, action_id, action)
if action_id == hash("space") then
if action.pressed then
physics.set_gravity(vmath.vector3(0.0, -2000.0, 0.0))
print("gravity enabled")
end
end
end
The problem is that the dynamic object comes to rest when the gravity is disabled. The object will not wake up because of the change in gravity in the scene. Instead of you need to manually wake it up: