Hi,
Does anyone know where to get the complete python script for joystick control?
Regards,
Robert Pember
Hi,
Does anyone know where to get the complete python script for joystick control?
Regards,
Robert Pember
Hi rpember ,
I would be interested in this myself. I think this is one of the areas where the game engine falls down. When you’re trying to compete with modern games you can’t expect people to want to mess around with keyboard controls. I know Blender and the game engine are really great, but I’d love to be able to make games with joystick controls.
jrt.
I want that script too, but how would you use it once you got it? I don’t know how to plug it in.
Good question. Any script for joystick/mouse/keyboard needs to be provided with a basic method of obtaining input data from that device. There simply is no way to obtain data from a joystick in blender. But it would be possible to write a c/c++ program for obtaining data from a joystick. that program could be compiled and run simultaneously to blender. It could then pass the data to blender using a socket or maybe a cache file. Blender could then read that data using python, but it would probably be really sluggish, and would be platform dependant.
Well, somebody posted here a game with joystick-support some time ago. But I do not remember who it was or how the thread was called. But it was coded in Python if I remember right. I will try to find the thread when I’ve got more time to do so…
You can still use the pygame-libraries (http://www.pygame.org/). I don’t know if the current versions would work with Blender because they need Python 2.2 - but older versions should work, I think. Still I haven’t tried it out (since I am no great python-coder and didn’t feel the need for trying it out), so I can’t tell for sure. Pygame uses the SDL and is platform independent.
You would use such a script the same way you use other python-scripts in the gameengine. Look at sample blend-files to see how they are linked in logic-bricks (there is a controller-type called python). Since you can’t use ‘endless’ loops in those scripts, you would create an always-sensor and link it to the script. There it should be possible to read the joystick and give back to Blender what you need.
To create a .exe of such a game it mostly had to be dynamic and you’d give the needed .dlls (or .so in Linux) along the .exe.
But still this are things I am now assuming since I haven’t tried it out.
(P.S.: I found the posting some months ago when I was browsing most of the forums at elysiun. So it still should be somewhere - even if I haven’t found it yet…)
i agree joystick and saving/loading are a must for the game engine.