Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

how to refrence a variable from other script in c#

public class PlayerScript: MonoBehaviour {
    public float Health = 100.0f;
}

public class Accessor : MonoBehaviour {
    void Start()
    {
        GameObject thePlayer = GameObject.Find("ThePlayer");
        PlayerScript playerScript = thePlayer.GetComponent<PlayerScript>();
        playerScript.Health -= 10.0f;
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to change the volume of all sound effects in monogame 
Csharp :: C# Floating Point Literals 
Csharp :: system.text.json ways to go about getting to the data how to get the data text.json you should use JsonDocument when 
Csharp :: c# encrypt folder SHA512 
Csharp :: 409 conflict 
Csharp :: c# deeply related children 
Csharp :: Last N lines from file 
Csharp :: array hw exercise 
Csharp :: c# delegates 
Csharp :: asp.net mvc select from many to many relationship 
Csharp :: winforms lifecycle 
Csharp :: ienumerable tolist 
Csharp :: bash clean-up code 
Csharp :: class combining 
Csharp :: C# Fibonacci list 
Csharp :: who is dani? game dev 
Csharp :: credit card validation in c# 
Csharp :: Enum into table C# 
Csharp :: cmd command see which groups a user is in 
Csharp :: c# open folder in explorer zugriff verweigert 
Csharp :: download and run exe c# 1 button 
Csharp :: how to disable button until the value is selected c# 
Csharp :: access form in a folder C# 
Csharp :: c# switch expression 8.0 
Csharp :: linq select distinct 
Csharp :: ef core totable 
Csharp :: dotnet core ef add multiple records 
Csharp :: unity timer 
Csharp :: Post and Pre Increment operators in C# 
Csharp :: enum extends dictionary c# 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =