예제 #1
0
    Text playerNameText; //Nome do seu personagem

    private void Start()
    {
        if (Weapon == null)
        {
            Weapon = Instantiate(Resources.Load <Weapon>("Prefabs/DemFists"), transform.position, Quaternion.identity);
            CharacterCommands.CatchWeapon(this, Weapon.gameObject);
        }
        if (GetComponentInChildren <Canvas>())
        {
            playerNameText      = GetComponentInChildren <Text>(); //PlayerNameText é um componente do canvas filho do prefab. Deve ser referenciado dessa maneira para que o nome do seu personagem apareça na tela do jogo
            playerNameText.text = PlayerName;
        }
    }
예제 #2
0
 private void OnTriggerEnter2D(Collider2D col)
 {
     if (col.transform == target)
     {
         if (col.tag == "Food")
         {
             CharacterCommands.CatchFood(chara, col.gameObject);
         }
         if (col.tag == "Weapon")
         {
             CharacterCommands.CatchWeapon(chara, col.gameObject);
         }
         if (col.tag == "Treasure")
         {
             CharacterCommands.CatchTreasure(chara, col.gameObject);
         }
         target = null;
     }
 }