Closed alciomarhollanda closed 1 year ago
` using System.Collections; using System.Collections.Generic; using UnityEngine;
public class NewBehaviourScript : MonoBehaviour // NewBehaviourScript : MonoBehaviour { //variaveis do objeto que aparecem no projeto // Start is called before the first frame update [SerializeField]private int NumeroDeQuartos = 2; [SerializeField]private int NumeroDePortas = 3;
private MeshRenderer MeshRenderer;
private float horizontal; private float vertical; [SerializeField]private int velocidade;
void Start()
{
NumeroDePortas = 3;
NumeroDeQuartos = 2;
MeshRenderer = GetComponent<MeshRenderer>();
}
// Update is called once per frame
void Update()
{
Sumir();
Mover();
}
//Mover o objeto void Mover(){ horizontal = Input.GetAxis("Horizontal"); vertical = Input.GetAxis("Vertical");
transform.Translate(new Vector3(horizontal,vertical,0)Time.deltaTimevelocidade);
}
//animaçao de desativar o objeto
void Sumir(){
if (Input.GetKeyDown(KeyCode.C)){
gameObject.SetActive(!gameObject.activeSelf);
}
} } `
Script em C# do objeto casa
`using System.Collections; using System.Collections.Generic; using UnityEngine;
public class NewBehaviourScript : MonoBehaviour // NewBehaviourScript : MonoBehaviour { //variaveis do objeto que aparecem no projeto // Start is called before the first frame update [SerializeField]private int NumeroDeQuartos = 2; [SerializeField]private int NumeroDePortas = 3;
private float horizontal; private float vertical; [SerializeField]private int velocidade;
//Mover o objeto void Mover(){ horizontal = Input.GetAxis("Horizontal"); vertical = Input.GetAxis("Vertical");
transform.Translate(new Vector3(horizontal,vertical,0)Time.deltaTimevelocidade);
} //animaçao de desativar o objeto void Sumir(){ if (Input.GetKeyDown(KeyCode.C)){ gameObject.SetActive(!gameObject.activeSelf); }
} }`