Thanks Kevin, it works. But i just remembered i don’t want the object to be affected by gravity, or at least prevent it from moving along the Z axis.
I can do it with the logic bricks, using motion, liniar along my y axis with value of 20, and next to it there is an ‘L’ and an ‘A’ where i only checked the L.
Just gotta seperate functions that need to be in a true level triggering impulse script, and those that don’t.
My script for firing a missile don’t have to run all the time, but the setLinearVelocity does.
That reminds me… can i write in a script import some_name_of_some_other_script.py, and use variables from it? Can they… speak to each other?
I sort of miss some kinds of global variables, instead of assigning game properties.
For thumb projectiles (like cannon balls) use the addObject actuator it allows to set up an initial velocity via GUI.
For a rocket like behavior add the “engine” to the rocket rather than the barrel. This means the rocket moves itself forward (Motion actuator)
To cancel out gravity apply a constant force against the scene gravity (global Z). Take care of the projectiles mass. The motion actuator fits perfect in this situation.
Keep “firing projectile”, “running rocket” and “cancelling out gravity” separate. You will see it makes your design much simpler.
If you miss “global variables” you most-likely have a weak design.
No, you can’t use variables form other Python controllers. Why would you do that? Your code should not know how the other code works. You can access the properties of the game objects. So you can use them for communication. Also message are pretty good with such things.