Parte2 – o meu projeto (aprender)
o GameDesign deste projeto:
a experiência do jogador ( player experience ) : agilidade
a mecânica do jogo ( core mechanic ) : movimentos, e de evitar obstáculos
o modo continuo do jogo ( game loop ): ir de a para b
coisas interessantes:
a função Time.deltaTime
usar o cinemachine (para termos acesso a diferentes camaras) +infos: LINK
box colider (lidar com as colisões)
rigidbody (vai permitir trabalhar as colisões, lidar com problemas de rotação, através de congelar (freeze nos constrains)
cores +infos: LINK
GameObject.GetComponent + infos: LINK
Time.time +infos: LINK
Tags +infos: LINK
Transform +infos: LINK
algum código:
using System.Collections; using System.Collections.Generic; using UnityEngine; public class ColisaoMuros : MonoBehaviour { private void OnCollisionEnter(Collision other) { //Debug.Log("colisao com um muro"); //Collision, tipo de variavel //other, quem colidiu comigo //OnCollisionEnter, quando "entra" na colisão //se colidirem contigo muda de cor //GetComponent<MeshRenderer>().material.color = Color.grey; //2) a colisão só deve acontecer se for com o objecto do jogador if(other.gameObject.tag == "Player"){ GetComponent<MeshRenderer>().material.color = Color.grey; //mudar a tag gameObject.tag = "colisao"; } } }
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Mover : MonoBehaviour { //para ficar disponivel no inspctor usamos o [SerializeField] //[SerializeField] float andaX = 0.0f; //[SerializeField] float andaY = 0.01f; //[SerializeField] float andaZ = 0.0f; // Start is called before the first frame update float andaY = 0.0f; [SerializeField]float movimentoVelocidade = 6.0f; void Start() { Debug.Log("parte 2 - inicio do jogo"); ImprimirInstrucoes(); //para mover } // Update is called once per frame void Update() { MoverOJogador(); } void ImprimirInstrucoes(){ Debug.Log("Bem vindo ao jogo"); Debug.Log("Move o jogador com as setas ou WSAD"); Debug.Log("Não vás contras os muros.."); } void MoverOJogador(){ float andaX = Input.GetAxis("Horizontal")*Time.deltaTime*movimentoVelocidade; float andaZ = Input.GetAxis("Vertical")*Time.deltaTime*movimentoVelocidade; transform.Translate(andaX, andaY, andaZ); } }
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Pontuacao : MonoBehaviour { int pontuacao = 0; private void OnCollisionEnter(Collision other) { if(other.gameObject.tag != "colisao"){ pontuacao=pontuacao+1; Debug.Log("pontos: "+pontuacao); } } }
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Queda : MonoBehaviour { [SerializeField] float TempoACorrer = 3.0f; MeshRenderer rendererizacao; Rigidbody corpoDoMuro; void Start() { //esconder a mesh do objeto //GetComponent<MeshRenderer>().enabled = false; rendererizacao = GetComponent<MeshRenderer>(); rendererizacao.enabled = false; corpoDoMuro = GetComponent<Rigidbody>(); corpoDoMuro.useGravity = false; } void Update() { //Time.time, o tempo que passou desde o inicio de play no jogo //Debug.Log(Time.time); if(Time.time > TempoACorrer){ //Debug.Log("ja passaram 3 segundos"); rendererizacao.enabled = true; corpoDoMuro.useGravity = true; } } }
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Roda : MonoBehaviour { [SerializeField] float rodaX = 0.0f; [SerializeField] float rodaY = 0.50f; [SerializeField] float rodaZ = 0.0f; // Update is called once per frame void Update() { transform.Rotate(rodaX,rodaY,rodaZ); } }
Tags : omeuprojeto, Unity, Unity 3D
0 thoughts on “Parte2 – o meu projeto (aprender)”