Custom commands
How to create a command
using UnityEngine;
using Ghostlike.Commands;
public static class NumberCommands
{
[Command]
public static int RandomNumber(int from, int to)
{
return Random.Range(from, to);
}
}using UnityEngine;
using Ghostlike.Commands;
public class Player : MonoBehaviour
{
[SerializeField] private float maxHealth;
private float currentHealth;
[Command]
public int Heal(int amount)
{
currentHealth += amount;
currentHealth = Mathf.Clamp(currentHealth, 0, maxHealth);
}
}Last updated