void FixedUpdate() { Vector2 newVelocity = physics.velocity; #region ENABLE_UPDATE if (global.GetComponent <GlobalVars>().processing == 0) { enabled = true; } else { enabled = false; } #endregion #region COLLISION_CHECKING if (colliderIndex > 0) { isColliding = true; } else { isColliding = false; } #endregion #region KEY_EVENTS if (enabled) { #region DOWN_EVENTS if (Input.GetKey(down)) { animator.speed = animationSpeed; facing.facingDirection = FACING.Down; animator.SetInteger("Direction", 2); if (Input.GetKey(left)) { newVelocity.x -= walkSpeed; } else if (Input.GetKey(right)) { newVelocity.x += walkSpeed; } newVelocity.y -= walkSpeed; } #endregion #region UP_EVENTS else if (Input.GetKey(up)) { animator.speed = animationSpeed; facing.facingDirection = FACING.Up; animator.SetInteger("Direction", 0); if (Input.GetKey(left)) { newVelocity.x -= walkSpeed; } else if (Input.GetKey(right)) { newVelocity.x += walkSpeed; } newVelocity.y += walkSpeed; } #endregion #region LEFT_EVENTS else if (Input.GetKey(left)) { animator.speed = animationSpeed; facing.facingDirection = FACING.Left; animator.SetInteger("Direction", 3); if (Input.GetKey(up)) { newVelocity.y += walkSpeed; } else if (Input.GetKey(down)) { newVelocity.y -= walkSpeed; } newVelocity.x -= walkSpeed; } #endregion #region RIGHT_EVENTS else if (Input.GetKey(right)) { animator.speed = animationSpeed; facing.facingDirection = FACING.Right; animator.SetInteger("Direction", 1); if (Input.GetKey(up)) { newVelocity.y += walkSpeed; } else if (Input.GetKey(down)) { newVelocity.y -= walkSpeed; } newVelocity.x += walkSpeed; } #endregion #region NO_KEY_EVENTS else { animator.speed = 0.0f; newVelocity.x = 0; newVelocity.y = 0; } #endregion #region FACING_TRIGGER_UPDATE facing.changeFacingTrigger(facing.facingDirection); #endregion #region PHYSICS_UPDATE // Update the rigidbody physics.velocity = newVelocity; #endregion } #endregion } // Physics Updates (Movement, L-R-U-D Key Events, Collision Detections, Calls to FacingTrigger Methods, etc...