Colocar O tempo restante do Ie numerator em um texto
2 participantes
Página 1 de 1
Colocar O tempo restante do Ie numerator em um texto
Bom Como não gosto de pedir script pronto com um pouco de dificuldade criei este script que exibe uma mensagem na tela do jogador quando ele ultrapassa o limite do mapa e caso o tempo passe ele e teleportado
quem poder ajudar agradeço :D
- Código:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AnimController : MonoBehaviour {
public Animator IMAGEM;
//private float Tempoespera = 10; variavel inutil
public GameObject Player;
// Use this for initialization
void Start () {
IMAGEM.GetComponent<Animator> ();
}
// Update is called once per frame
void OnTriggerEnter () {
IMAGEM.SetBool ("estasaindo", true);
StartCoroutine ("ReposicionarPlayer");
}
void OnTriggerExit () {
IMAGEM.SetBool ("estasaindo", false);
StopCoroutine ("ReposicionarPlayer");
}
IEnumerator ReposicionarPlayer(){
yield return new WaitForSeconds (10.0f);
Player.transform.position = new Vector3 (133, 56,148);
}
}
quem poder ajudar agradeço :D
BRGC- ProgramadorMaster
- PONTOS : 2814
REPUTAÇÃO : 59
Idade : 19
Áreas de atuação : C#, C++, C, Flutter
Respeito as regras :
Re: Colocar O tempo restante do Ie numerator em um texto
tenta assim:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AnimController : MonoBehaviour {
public Animator IMAGEM;
//private float Tempoespera = 10; variavel inutil
public GameObject Player;
private float TimeCount = 10;
public Text TextoTime;
// Use this for initialization
void Start () {
IMAGEM.GetComponent<Animator> ();
}
// Update is called once per frame
void OnTriggerEnter () {
IMAGEM.SetBool ("estasaindo", true);
StartCoroutine ("ReposicionarPlayer");
TextoTime.text = "0 : " + TimeCount;
TimeCount -= Time.deltaTime;
}
void OnTriggerExit () {
IMAGEM.SetBool ("estasaindo", false);
StopCoroutine ("ReposicionarPlayer");
TextoTime.text = "";
TimeCount = 10;
}
IEnumerator ReposicionarPlayer(){
yield return new WaitForSeconds (10.0f);
Player.transform.position = new Vector3 (133, 56,148);
TimeCount = 10;
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AnimController : MonoBehaviour {
public Animator IMAGEM;
//private float Tempoespera = 10; variavel inutil
public GameObject Player;
private float TimeCount = 10;
public Text TextoTime;
// Use this for initialization
void Start () {
IMAGEM.GetComponent<Animator> ();
}
// Update is called once per frame
void OnTriggerEnter () {
IMAGEM.SetBool ("estasaindo", true);
StartCoroutine ("ReposicionarPlayer");
TextoTime.text = "0 : " + TimeCount;
TimeCount -= Time.deltaTime;
}
void OnTriggerExit () {
IMAGEM.SetBool ("estasaindo", false);
StopCoroutine ("ReposicionarPlayer");
TextoTime.text = "";
TimeCount = 10;
}
IEnumerator ReposicionarPlayer(){
yield return new WaitForSeconds (10.0f);
Player.transform.position = new Vector3 (133, 56,148);
TimeCount = 10;
}
}
Phph09- Profissional
- PONTOS : 3551
REPUTAÇÃO : 240
Idade : 18
Respeito as regras :
Re: Colocar O tempo restante do Ie numerator em um texto
Se esse não der certo tenta esse:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AnimController : MonoBehaviour {
public Animator IMAGEM;
//private float Tempoespera = 10; variavel inutil
public GameObject Player;
private float TimeCount = 10;
public Text TextoTime;
// Use this for initialization
void Start () {
IMAGEM.GetComponent ();
}
// Update is called once per frame
void OnTriggerEnter () {
IMAGEM.SetBool ("estasaindo", true);
StartCoroutine ("ReposicionarPlayer");
TextoTime.text = "0 : " + TimeCount;
}
void OnTriggerStay(){
TimeCount -= Time.deltaTime;
}
void OnTriggerExit () {
IMAGEM.SetBool ("estasaindo", false);
StopCoroutine ("ReposicionarPlayer");
TextoTime.text = "";
TimeCount = 10;
}
IEnumerator ReposicionarPlayer(){
yield return new WaitForSeconds (10.0f);
Player.transform.position = new Vector3 (133, 56,148);
TimeCount = 10;
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AnimController : MonoBehaviour {
public Animator IMAGEM;
//private float Tempoespera = 10; variavel inutil
public GameObject Player;
private float TimeCount = 10;
public Text TextoTime;
// Use this for initialization
void Start () {
IMAGEM.GetComponent ();
}
// Update is called once per frame
void OnTriggerEnter () {
IMAGEM.SetBool ("estasaindo", true);
StartCoroutine ("ReposicionarPlayer");
TextoTime.text = "0 : " + TimeCount;
}
void OnTriggerStay(){
TimeCount -= Time.deltaTime;
}
void OnTriggerExit () {
IMAGEM.SetBool ("estasaindo", false);
StopCoroutine ("ReposicionarPlayer");
TextoTime.text = "";
TimeCount = 10;
}
IEnumerator ReposicionarPlayer(){
yield return new WaitForSeconds (10.0f);
Player.transform.position = new Vector3 (133, 56,148);
TimeCount = 10;
}
}
Phph09- Profissional
- PONTOS : 3551
REPUTAÇÃO : 240
Idade : 18
Respeito as regras :
Tópicos semelhantes
» Exibir um texto na tela por um tempo
» Aparecer Texto por um Certo tempo
» Como colocar valor float em um texto na UI unity
» como posso colocar tempo em qualquer script?
» Mudando cor do texto...
» Aparecer Texto por um Certo tempo
» Como colocar valor float em um texto na UI unity
» como posso colocar tempo em qualquer script?
» Mudando cor do texto...
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos