Should Getaxis reading be on Update?

Hello there,

I’ve recently read some articles about the relationships between Update and FixedUpdate.

In particular, I’ve seen that you should check for button or key press on the Update function and then read a boolean from the Fixed Update, to make sure that the input is effectively registered.

That makes a lot of sense.

In my control script, though, I need to check the analog input axis. For now I read it from the fixed update, and I manage animations from there also.

Should I change it moving the input and animation part to the Update function, or for continuous input there is no problem?

Here my fixed update script:

	void FixedUpdate () {
		if(rigidbody.velocity.magnitude <= maxSpeed) rigidbody.AddRelativeForce(Vector3.forward*accel);
		var inputX = Input.GetAxis("Horizontal");
		
		anim.SetFloat("Turn", inputX);
		
		if ((inputX < -0.1f) || (inputX>0.1f)) anim.SetBool("isTurning", true);
		else anim.SetBool("isTurning", false);
		
		var x = inputX * Time.deltaTime * rotateSpeed;
		rigidbody.AddRelativeTorque(0, x, 0);
		
		//if it's no more playing the hit animation and hit is still true, it sets hit to false.
		if (anim.GetBool("Hit")  anim.GetNextAnimatorStateInfo(0).IsName("Base Layer.Hit")) 
		{
			
			//Debug.Log(anim.GetBool("Hit"));
			anim.SetBool("Hit", false);
			
		}

It would be better to move everything non-physics-related into Update.

–Eric

Ok, so, animations will be for sure moved to update.
What do you advise about getaxis? This could be borderline, because that value is not just a boolean, but a value that affects physics, because it’s then applied to torque.