【发布时间】:2018-06-22 22:06:42
【问题描述】:
这是我需要它做的。
让计时器只在停留在触发器中时减少,并在触发器之外时重置。
当 timer1 = 0 时,暂停倒数计时器并将瞬移设置为 0
当 timer1 = 1 时,设置定时器为 8 秒并开始倒计时,IF timercountdown = 0,将teleport设置为1并将Timer1设置为0。(重置计时器)
这不能正常工作,我真的不知道为什么。
计时器锁定在 8 点,当 Timer1 的值等于 1 时不会开始减少。
谢谢
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ProximityTeleport : MonoBehaviour {
public float time;
public int timer1 = 0;
public int teleport = 0;
public float timecountdown;
void Start () {
}
void Update () {
if (timer1 == 0);
{
teleport = 0;
}
if (timer1 == 1);
{
timecountdown -= Time.deltaTime;
if (timecountdown <= 0.0f);
{
teleport = 1;
timer1 = 0;
}
}
}
void OnTriggerEnter() {
timecountdown = 8f;
timer1 = 1;
}
void OnTriggerExit() {
timer1 = 0;
}
}
【问题讨论】: