I want to control my box2d based character using the accelerometer on the iPhone.
I only want control over one axis, I want to be able to tilt the phone to the right and the character shall move to the right and vice versa.
Currently I do this by adding a pulse to the character based on the x vale of the acceleration. This is not working very well, since there will be inertia in the movement, I want the character to be very precise and quick in its movement. I also tried positioning the character based on the angle (acceleration) but there is a lot of jitter and it is not very precise, so I think I need to find some other way to control the position.
I was thinking maybe accelerations close to zero (with som delta) should result in the velocity vector being set to zero, but that would interfere with the physics simulation and the characters interaction with the rest of the world.
I should add that the character is confined in a room that is the size of the screen, but can interact with objects and walls, so that he can get knocked around a bit, both along the x and y-axises.
Any suggestions?
I only want control over one axis, I want to be able to tilt the phone to the right and the character shall move to the right and vice versa.
Currently I do this by adding a pulse to the character based on the x vale of the acceleration. This is not working very well, since there will be inertia in the movement, I want the character to be very precise and quick in its movement. I also tried positioning the character based on the angle (acceleration) but there is a lot of jitter and it is not very precise, so I think I need to find some other way to control the position.
I was thinking maybe accelerations close to zero (with som delta) should result in the velocity vector being set to zero, but that would interfere with the physics simulation and the characters interaction with the rest of the world.
I should add that the character is confined in a room that is the size of the screen, but can interact with objects and walls, so that he can get knocked around a bit, both along the x and y-axises.
Any suggestions?