Switching sizes changes the player’s scale and stats at runtime. We stored three presets (Big, Medium, Small) and simply applied the corresponding values when the player pressed a size key.
SizeStats Script
public class SizeStats : MonoBehaviour
{
#region StatsLists
List statsSmall, statsMedium, statsLarge;
#endregion
#region SizeParameters
[Header("Size Parameters")]
[Range(0,3)] public float sizeSmall = 0.25f;
[Range(0,3)] public float sizeMedium = 0.75f;
[Range(0,3)] public float sizeLarge = 1.25f;
#endregion
#region MovementStats
[Header("Movement Stats")]
[Range(0,100)] public float speedSmall = 10;
[Range(0,100)] public float speedMedium = 6;
[Range(0,100)] public float speedLarge = 4;
[Space(10)]
[Range(0,100)] public float accelerationSmall = 30;
[Range(0,100)] public float accelerationMedium = 20;
[Range(0,100)] public float accelerationLarge = 10;
[Space(10)]
[Range(0,100)] public float deaccelerationSmall = 10;
[Range(0,100)] public float deaccelerationMedium = 20;
[Range(0,100)] public float deaccelerationLarge = 30;
#endregion
#region JumpStats
[Header("Jump Stats")]
[Range(0,50)] public float jumpHeightSmall = 4;
[Range(0,50)] public float jumpHeightMedium = 6;
[Range(0,50)] public float jumpHeightLarge = 8;
[Space(10)]
[Range(0,100)] public float fallSpeedSmall = 1;
[Range(0,100)] public float fallSpeedMedium = 2;
[Range(0,100)] public float fallSpeedLarge = 3;
[Space(10)]
[Range(0,1)] public float jumpCutOffSmall = 0.5f;
[Range(0,1)] public float jumpCutOffMedium = 0.1f;
[Range(0,1)] public float jumpCutOffLarge = 0.005f;
#endregion
#region GroundCheckSizes
[Header("Ground Check Sizes")]
float groundCheckSizeSmallX, groundCheckSizeMediumX, groundCheckSizeLargeX;
float groundCheckSizeSmallY, groundCheckSizeMediumY, groundCheckSizeLargeY;
#endregion
#region AirMultipliers
[Header("Air Multipliers")]
[Range(0,10)] public float airSpeedMultiSmall = 0.9f;
[Range(0,10)] public float airSpeedMultiMedium = 1f;
[Range(0,10)] public float airSpeedMultiLarge = 1f;
[Space(10)]
[Range(0,10)] public float airAccMultiSmall = 1f;
[Range(0,10)] public float airAccMultiMedium = 1f;
[Range(0,10)] public float airAccMultiLarge = 1f;
[Space(10)]
[Range(0,10)] public float airDecMultiSmall = 0.9f;
[Range(0,10)] public float airDecMultiMedium = 0.9f;
[Range(0,10)] public float airDecMultiLarge = 0.9f;
#endregion
#region LandingSfxOffsets
[Header("Landing SFX Offsets")]
public float landingSfxOffsetSmall = 0.05f;
public float landingSfxOffsetMedium = 0.1f;
public float landingSfxOffsetLarge = 0.5f;
#endregion
void Start()
{
UpdateStatValues();
}
public List ReturnStats(Sizes size)
{
if (size == Sizes.SMALL) return statsSmall;
if (size == Sizes.BIG) return statsLarge;
return statsMedium;
}
private void UpdateStatValues()
{
// (Populate stats lists as before…)
}
}