Created
April 8, 2021 06:46
-
-
Save GT3000/661bae1d0b057abbc6af6d1d796debc2 to your computer and use it in GitHub Desktop.
Variables Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Player : MonoBehaviour | |
{ | |
//Value Types | |
private int health = 100; | |
private float speed = 5.0f; | |
public bool isAlive = true; | |
//Reference Types | |
public Transform tran; | |
private void Start() | |
{ | |
//These variables are directly changed | |
health = 0; | |
speed = 0f; | |
isAlive = false; | |
//The variables referenced never change but data they hold the location of does | |
//The position of transform is never touched but the positon of tran does change from transform since it copied it | |
tran = transform; | |
tran.positon = new Vector3(1, 1, 1) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment