Exemplo n.º 1
0
 public void Awake()                 // Singleton: Destroys itself in case another instance is already in the scene
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
Exemplo n.º 2
0
    public void Start()
    {
        _sprite   = transform.FindChild("Sprite");              // Reference to the character sprite
        _rb       = this.GetComponent <Rigidbody2D>();          // Assign components to variables
        _anim     = _sprite.GetComponent <Animator>();
        _cam      = PB_Camera.instance;
        _saveXpos = transform.position.x;                                       // Save start position of player
        Rigidbody2D r = gameObject.GetComponent <Rigidbody2D>();

        r.gravityScale *= PB_GameController.instance._gameSpeed;
        r.mass         *= 1 + (1 - PB_GameController.instance._gameSpeed);
    }
Exemplo n.º 3
0
    public static PB_Camera instance;                           // PB_Camera is a singleton. PB_Camera.instance.DoSomeThing();


    public void OnApplicationQuit()                                                     // Ensure that the instance is destroyed when the game is stopped in the editor.
    {
        instance = null;
    }