我正試圖學習如何在youtube上使用gamesplusjames來做到這一點,但它工作不太好。我很確定這是一件小事,但我無法弄清楚它是什麼。基本上,當我釋放C鍵時,我的角色瞄準她的弓箭和射擊。但是我需要延遲,所以她的動作不會比她的動畫更快。任何人都可以告訴我我丟球的位置嗎?我簡化了我的代碼,擺脫了與拍攝或瞄準無關的所有其他垃圾。謝謝。如何讓我的拍攝延遲工作
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class tulMove : MonoBehaviour {
public Transform arrowSpawn;
public GameObject arrowPrefab;
private bool aim = false;
private bool shot = false;
public float shotDelay;
private float shotDelayCounter;
private Rigidbody2D rb;
private Animator anim;
void Start()
{
anim = GetComponent<Animator>();
rb = GetComponent<Rigidbody2D>();
}
void Update(){
if (!aim && Input.GetKeyDown (KeyCode.C))
{
aim = true;
anim.SetTrigger ("aim");
}
if (aim && !shot && Input.GetKeyUp (KeyCode.C))
{
shot = true;
aim = false;
anim.SetTrigger ("shot");
Instantiate (arrowPrefab, arrowSpawn.position, arrowSpawn.rotation);
shotDelayCounter = shotDelay;
}
if (aim && !shot && Input.GetKeyUp (KeyCode.C))
{
shotDelayCounter -= Time.deltaTime;
if (shotDelayCounter <= 0)
{
shotDelayCounter = shotDelay;
shot = true;
aim = false;
anim.SetTrigger ("shot");
Instantiate (arrowPrefab, arrowSpawn.position, arrowSpawn.rotation);
}
}
}
}
你能張貼鏈接到視頻,並介紹目前的問題呢?如在,你是否暗示動畫目前速度太快? – SpiritBH
那麼視頻並不完全適合我的情況,但肯定。這就像20分鐘,但他只是在幾分鐘內完成計時器的事情,然後轉向健康,這是不相關的。 https://www.youtube.com/watch?v=F6hUIU72JwE –
抱歉,如果我不清楚。我只是想讓計時器基本工作。現在我沒有得到結果。我可以調整下一個箭頭出來的時間,這個時間不是問題。首先讓代碼工作是一個問題。 –