Komut dizim/oyun/şey sağa doğru bir hamle hareketi yapar ve ben dansı tıkladığımda (oluşturduğum bir düğme) durur. Daha sonra sayaç (bir sayaca ihtiyaç duymayabilirim ama 3 saniye beklemek istiyorum) 3'e ulaştığı zaman (sayacı dansa tıkladığınızda dans başladığında), gameobject’imin sağa gitmeye devam edeceği varsayılır.3 saniye bekleyip C# olarak bir boole doğru olarak nasıl bekleyebilirim?
Takılı olabilecek kodu düzeltebilirseniz. Eğer düzeltip bana neyi yanlış yaptığımı açıklarsanız daha da harika olur. Sadece C# 'yı Unity' de öğrenmeye başladım.
using System;
using UnityEngine;
using System.Collections;
public class HeroMouvement : MonoBehaviour
{
public bool trigger = true;
public int counter = 0;
public bool timer = false;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{ //timer becomes true so i can inc the counter
if (timer == true)
{
counter++;
}
if (counter >= 3)
{
MoveHero();//goes to the function moveHero
}
if (trigger == true)
transform.Translate(Vector3.right * Time.deltaTime); //This moves the GameObject to the right
}
//The button you click to dance
void OnGUI()
{
if (GUI.Button(new Rect(10, 10, 50, 50), "Dance"))
{
trigger = false;
timer = true;//now that the timer is set a true once you click it,The uptade should see that its true and start the counter then the counter once it reaches 3 it goes to the MoveHero function
}
}
void MoveHero()
{ //Set the trigger at true so the gameobject can move to the right,the timer is at false and then the counter is reseted at 0.
trigger = true;
timer = false;
counter = 0;
}
}
Sen boşluk kolay gitmek gerekir ... – paddy
evet, çizgilerin 1/5 yaşadım olabilir! – ApolloSoftware
klocs içinde ödenmelidir :) – ApolloSoftware