Game Development Community

Anyone got accelerometer working?

by Daryll Todd · in iTorque 2D · 10/18/2008 (7:21 am) · 12 replies

Has anyone managed to get the accelerometer working?

Ive found a shooterControls.cs behavior in the shooter demo which contains some iPhone specific stuff, been trying to use/pick it apart but dont seem to be getting anywhere.

Maybe ive just been looking at this too long now, need some more caffeine ;)

#1
10/18/2008 (8:53 am)
Yes, check out the iPhoneTest game that comes with 1.0.1.
The accelerometer is assigned as joystick.
#2
10/18/2008 (10:01 am)
Yeah had no problems
you just have to open main.cs in your game folder and change the input type in the global there to Accelerometer from Touch
#3
10/19/2008 (5:10 am)
Ok thanks guys, I think its to do with my ported project again.

I couldnt get sound to work either so ive created a new project with iTGB and copied all my files across to it, the sound started working straight away :) I imagine ill have more luck with the accelerometer too, gonna go and have a play.
#4
10/19/2008 (6:08 am)
Hmm still no luck with this, noticed I get the following error though:

game/gameScripts/game.cs (22): Unable to find function enableJoystick

Is that going to cause a problem on the iPhone?
#5
10/19/2008 (7:14 am)
Did you assign a joystick control scheme? There is one behavior that includes an iphone joystick mapping (don't know out of head which one, just check through their sources in behavior/input for the one with iPhone in. it is only a single one)
#6
10/19/2008 (7:45 am)
Yeah I found that, its the ShooterControls behaviour, tried using it but it doesnt seem to have any affect, ill keep digging lol.
#7
10/19/2008 (8:14 am)
Did you change the input type in game/main.cs?

as long as you have touch, the accelerometer will be ignored
#8
10/19/2008 (9:55 am)
Yeah id changed that, sorted it now, it was a number of things ;)

Thanks for your help :)

As a side note, does the save button actually work? In both TGB & iTGB if I save and then go to close the project it prompts me to save changes..
#9
10/19/2008 (11:11 am)
Good to hear.
The save button does work. I usually don't save the second time it prompts me since it's already saved.
#10
10/19/2008 (12:31 pm)
Ah ok then, thanks for confirming that :)
#11
10/19/2008 (11:07 pm)
@Marc - so you can't have touch and tilt at the same time?

That's no good! If you're doing a tilt controlled game you're at least going to want a touch-to-pause functionality.
#12
10/20/2008 (10:53 am)
You can, but in BehaviorShooter it's separated into two "modes". One mode is touch control (move to finger) the other is accelerometer(tilt to move), but Torque can handle both at the same time, like in the iPhoneTest gravity mode.