private void OnTriggerEnter2D(Collider2D collision) { ObstacleController obstacle = collision.gameObject.GetComponent <ObstacleController>(); CointController coint = collision.gameObject.GetComponent <CointController>(); GrassController grass = collision.gameObject.GetComponent <GrassController>(); if (obstacle != null) { angle = -60; gameControllerScript.End(); } else if (coint != null) { gameControllerScript.AddCoins(coint.value); coint.desroyCoint(); CoinMusic.Play(); } else if (grass != null) { angle = -60; gameControllerScript.End(); } }