我的脚本/游戏/东西使游戏对象向右移动,当我点击舞蹈(我创建的按钮)时,它停止.然后当计数器(我可能不需要计数器,但我想要等待3秒)达到3(一旦你点击舞蹈计数器开始)我的游戏对象假设继续向右移动.
如果你能纠正那些很酷的代码.如果你能纠正它并向我解释我做错了什么就会更加棒极了.我刚开始在Unity上学习C#.
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 …Run Code Online (Sandbox Code Playgroud)