# Why does my object “jump” immediately as the game starts?

I'm having a problem where, when I start my game, my game object (a 3D plane) immediately jumps 300 pixels or so. I suspect this has something to do with my joystick handling code that I've written to move this game object:

 xMin1 += Input.GetAxisRaw("LeftRight");
yMin1 += Input.GetAxisRaw("UpDown");

//_targetPlane is my game object
_targetPlane.transform.position = new Vector3(xMin1, yMin1, 2.5f);


The object jumps even if I don't touch the joystick. Am I doing this wrong?

• Do you run this in your update loop? When does the plane make the jump? When you move the joystick, or when you start the game? – bummzack Apr 22 '13 at 14:52
• Yes, this in my update method and it happens right when I start the game. Sorry, i should have made that clear. I'll edit now. – N0xus Apr 22 '13 at 14:54
• If it happens right at the start, how is it related to moving your plane using a joypad? Also: Did you debug the values you get from Input.GetAxisRaw? Note that incrementing your values will increase your offsets really fast (with each tick), which is most likely not what you want. – bummzack Apr 22 '13 at 14:56
• Do yMin1 & xMin1 initialize with zero? – Max Yankov Apr 24 '13 at 11:48
• Why did you roll back my edit, which was done to make the question fit the accepted style for the site? Please don't do that without good reason, questions that aren't titled as questions and don't specifically address the problem make the site less searchable and make it less likely that you will get answers. – user1430 Jan 6 '14 at 17:34

• Verify that both xMin and yMin are initialized to zero using your debugger. It might be useful to log them or to log the position of the object every frame, that may help identify the problem.
• If your joystick is not perfectly calibrated to rest at dead center (most aren't), you may be getting non-zero input even when the stick appears at rest (which will quickly accumulate and move your object). Log the values returns from GetAxisRaw to confirm this (Unity may or may not do the usual dead-zone computation to handle this for you, I'm not sure, but it's worth checking).
• Note that GetAxisRaw doesn't do smoothing, and generally the values returned by GetAxisRaw should be weighted by delta time, as in the linked example code from GetAxisRaw. You may alternatively want to consider GetAxis instead.