Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

unity action example

public static event Action<string> OnGameOver;
public void TakeDamage(float damage)
{
    health -= damage;
    if(health < 0)
    {
        OnGameOver?.Invoke("The game is over");
    }
}

// can have multiple paramethers, always return null (if you want that it 
// retur something you have to create your own event

public static event Action<string> OnGameOver;
public static event Action<float, bool> OnPlayerHurt;
Source by gamedevbeginner.com #
 
PREVIOUS NEXT
Tagged: #unity #action
ADD COMMENT
Topic
Name
3+1 =