PlayerMultipliers

Updated in 1.3.6

PlayerMultipliers can be used to create custom Power-Ups.

  • damageMultiplier: Used by WeaponController to determine Damage Power-Up.

  • healMultiplier: Used by the PlayerStats to determine Heal Power-Up.

  • playerWeightMultiplier: Used by PlayerMovement to determine Weight Power-Up

HOW TO CREATE CUSTOM MULTIPLIERS / POWER-UPS.

First, we need to add a new variable in PlayerMultiplier.cs. We'll name it playerSpeedMultiplier. Keep in mind that creating custom multipliers or power-ups can be very specific, so this tutorial will not cover the exact steps or requirements for your case.

 [ReadOnly] public float playerSpeedMultiplier;

NOTE: You can use ReadOnly to display the value in the Inspector for easier debugging, while keeping it unmodifiable ( from the Inspector, keep in mind this variable is public and can be modified programmatically )

To define the default value for playerSpeedMultiplier, set it to 1, since it acts as a multiplier (i.e., currentSpeed * playerSpeedMultiplier = currentSpeed when playerSpeedMultiplier is 1).

For a variable like playerSpeedAddition, which represents an additive value, set its default to 0. This ensures that currentSpeed + playerSpeedAddition = currentSpeed when playerSpeedAddition is 0.

Now, let's determine the default value for this new variable.

 private void Awake()
 {
     damageMultiplier = 1;
     healMultiplier = 1;
     playerWeightMultiplier = 1;
     // Our new variable
     playerSpeedMultiplier = 1;
 }

Locate the section in your code where a multiplication operation is required for your Custom Power-Up to function. Use your custom multiplier by referencing the PlayerMultipliers script.

If you need assistance, feel free to reach out for support!


PlayerMultipliers.cs can be found inside the same script.

Last updated