Update CollectCoins

This commit is contained in:
xixu-me committed 2025-03-27 09:04:59 +08:00
1 parent 31f39cfa92
commit cbf94c4b2e
55 files changed
+271 -20

No files matched your search

@@ -0,0 +1,40 @@
using UnityEngine;
using System.Collections;
public class TargetScript : MonoBehaviour {
bool beenDown = false;
Animation targetRoot;
public float recoveryTime = 5.0f;
GameObject player;
void Start () {
targetRoot = transform.parent.transform.parent.animation;
player = GameObject.Find("First Person Controller");
}
// Update is called once per frame
void Update () {
}
void OnCollisionEnter(Collision collision)
{
if (!beenDown && collision.gameObject.tag == "Bullet")
{
StartCoroutine("targetHit");
player.SendMessage("pickup");
}
}
IEnumerator targetHit()
{
targetRoot.Play("down");
beenDown = true;
yield return new WaitForSeconds(recoveryTime);
targetRoot.Play("up");
beenDown = false;
}
}