XBOX controller problem?

hey ho, i wrote this script, which should move a gameobject with the left thumbstick of my controller:

function FixedUpdate ()
{
var x : float = Input.GetAxis(“XBOX_leftH”)*20;
var y : float = Input.GetAxis(“XBOX_leftV”)*20;

rigidbody.AddForce(x,y,0);

}

(leftH = horizontal stick-movement, leftV = vertical stick-movement)

now the problem is, that when i start, my gamebject moves to the left!!! why?

PS: im pretty new at scripting, at this forum and im german :smile:

Did you calibrate your controller? Also in many cases there is a minimum movement on one of the axes - if you multiply that by 20 you will easily get movement. Per Frame. So consider multiplying by Time.fixedDeltaTime as well.

yeah i will try using a deadzone

If you set up your Left stick as an axis in the Input Manager then the values of your horizontal axis range from -1.0 to 1.0. You can check for these values or a little less so the player doesn’t have to whip the stick all the way. Something like -0.5f to 0.5f is what I use. Try this… It basically creates a dead zone in the center half of the stick: (You can of course adjust the values as needed)

function FixedUpdate () 
{
var x : float = 0.0f;
var y : float = 0.0f;

if(Input.GetAxis("XBOX_leftH") > 0.5f || Input.GetAxis("XBOX_leftH") < -0.5f){ 
    x = Input.GetAxis("XBOX_leftH")*20;
} 
if(Input.GetAxis("XBOX_leftV") > 0.5f || Input.GetAxis("XBOX_leftV") < -0.5f){ 
    y = Input.GetAxis("XBOX_leftV")*20;
}
rigidbody.AddForce(x,y,0);

}

untested code…