Pesquisar neste blog:

31/05/2020

Hide part of a character by C# code - UNITY 3D


The character was used in my first educacional game published (free) in Play Store: https://play.google.com/store/apps/details?id=com.gustavovanin.roboticmath


Reference in Unity site: Clique here

Resume: 
// in class
public GameObject player_part;

//in update
 if(Input.GetButtonDown("Action"))
{
  //print("B (X-Box) / E (keyboard)");
  player_part = GameObject.Find("/Character Controller/Player/corpo");
  player_part.SetActive(false);
}

Other options:
- playerObject.GetComponent<MeshRenderer>().enabled = false;
- GameObject.Find("corpo"); //find without path  

Thank you.

Nenhum comentário:

Postar um comentário

SIGA-NOS