Xinput assigned every frame?

Ok… I’ve just tried out the Xinput wrapper for Unity and I’ve noticed something that kinda bugs me.

This code sets up Player One’s Controller

public static void Update () {
        state = GamePad.GetState(PlayerIndex.One, GamePadDeadZone.None);
	}

this is just a simple initialization code, however its assigning a variable ever frame, the same variable to the same thing every frame. this code isn’t working in Start or Awake(it gets assigned but the input is completely ignored), most of us would like to keep initialization away from repeating calls like Update.

Why does this code require to be called on each frame? Why does Input get ignored if i Use it otherwise? if I am ignorant of how the code works please enlighten me.

Yeah you are ignorant of how it works :wink: Let me explain:

The state variable is the controllers input state, like all the button presses, thumbstick movement, everything.

It’s not just ‘initialization’ of the controller., it’s the entire state of the controller input. The input doesn’t work when you put it in Start or Awake because it depends on the state variable being constantly set to listen for the controllers inputs.