/// <summary> /// Returns the value of the axis as 1, -1 or 0. This will return the axis from a replay if one is being played. /// </summary> /// <param name="axis">The name of the axis</param> /// <returns>The value of the axis rounded to the nearest int</returns> public static float GetAxisRaw(string axis) { //Make sure there are axis values to read if (ReplayedAxisValues != null //Check if the axis is contained && ReplayedAxisValues.ContainsKey(axis)) { //If so, return the axis from the replay rounded to 1 or -1 float val = ReplayedAxisValues[axis]; //Check 0 first since it could be the most common if (val == 0) { return(0); } //Check positive and negative if (val > 0) { return(1); } if (val < 0) { return(-1); } } //Otherwise return Input.GetAxis return(Input.GetAxisRaw(axis)); }
/// <summary> /// Returns the value of the axis. This will return the axis from a replay if one is being played. /// </summary> /// <param name="axis">The name of the axis</param> /// <returns>The value of the axis</returns> public static float GetAxis(string axis) { //Make sure there are axis values to read if (ReplayedAxisValues != null //Check if the axis is contained && ReplayedAxisValues.ContainsKey(axis)) { //If so, return the axis from the replay return(ReplayedAxisValues[axis]); } //Otherwise return Input.GetAxis return(Input.GetAxis(axis)); }