Joystick Twist in the GE?

Does anyone know if there is a way to use a joystick twist with the joystick sensor? Or would that have to be done through Python?

I haven’t found much documentation on the joystick sensor and it only seems to support for 4 axis movement, buttons and directional hats.

Thanks!

Nope. It doesn’t support twist. Like you said, only axes, hats, and buttons. The documentation on the joystick sensor is especially poor. To get a listing of available Python functions, you can use dir() in Python.

cont = getCurrentController()
joystick = cont.getSensor("<i>your joystick sensor name</i>")

print dir(joystick)

It prints to the console window.

That’s what I suspected. Thanks for the tip.

Twist does work on the joy stick, axis 2.

Ah, works like a charm. Thanks rebogey.

What do Up and Down on Axis 2 control?

Hmm. I stand corrected. I guess that’s the problem with not having a joystick with twist to test it before I respond. Oh well…

Hi please someone. Where can i find the tutorial that shows me how to such a joystick with the GE. I’m a newbie and don’t know how to make the GE call the scripts.

all help would be appreciated.

thank you!

Everyone should have a twist handle joystick. Lots of fun when playing Freespace 2.

BTW there are four kinds of controllers, AND, OR, Expression, and Python. The latter is how you call scripts.

thanks!
I had a feel I was supposed to use that. And I asume I connect it to a sensor (“Always”). But when I write the path to the script in the controller(“where it says “Script:””), it disappears as soon as I leave that field. So I think I’m doing something wrong here…
Then I think I make the connection to a atuator in the code right? or do I connect it in Blender…
thanks for all!

PS. I’ve looked allover for a tutorial that covers this. Does anyone know where i can find one?

oy, the script must be IN the blend. Here’s an example:

http://www.4shared.com/file/14808740/21dbdffb/LoD.html

This blend uses python scripts, hopefully you can figure it out from there.

Thanks Mr crunchy.
I realize now I know less than I thought. It really hit me when I realized I don’t know how to save the script “IN the Blender”. I mean, I can save it on any location in my comp but I don’t know how to save it “IN the Blender”. i tried to look at the LoD-file but I cannot see where it is saved.
So I found this turtorial about scripting in Blender(http://feeblemind.tuxfamily.org/dotclear/share/blender-lg-01-en.pdf) but as soon I try to import Nmesh the way it says, the consol tells me: importError. cannot import Nmesh. Why is that? Nmesh should be a standar subclass to Blender.the same as Blender.Scene right?

Afroman

PS I’ve now found out how to save IN the Blender. Acidentally but stil…:slight_smile:

Hi again…

Have encountered another problem…
I’ve written this code:
import Blender as bl
import GameLogic as gl
import pygame
from pygame import joystick,event

joystick.init()
spacecat=joystick.Joystick(0)
spacecat.init()
controller=gl.getCurrentController()
right=controller.getActuator(“Right”)
left=controller.getActuator(“Left”)
event.pump()
eve=event.poll()

axis=eve.dict[‘axis’]
value=eve.dict[‘value’]
print eve
if axis==1 :
if value<0:
gl.addActiveActuator(right,1)
if value>0:
gl.addActiveActuator(left,1)

It should work for two directtions in one axis right? like right and left, up and down, right twist and left twist? the only thing that happens is that the camera(the object I’m trying to move) moves to the right and then down as a response to the joystick.
can you find any errors?

thanks

Looks to me like you only coded it to work in two directions. (at first glance)

Can I see the blend? I have a twist handle joystick to test it.