1
我正在製作一個像消防員一樣的遊戲,我有一個情景,機器因爲電力而着火,第一個玩家不得不關閉電源,所以我做了按鈕並顯示該按鈕o關掉電,但我無法摧毀電力對象,這是我迄今爲止的代碼,但沒有什麼進展。摧毀鍵盤按鈕上的對象按
using UnityEngine;
using System.Collections;
public class SwitchONOFF : MonoBehaviour {
public Transform Player;
public Texture texture;
// Use this for initialization
void Start() {
}
// Update is called once per frame
void OnGUI() {
float distance = Vector3.Distance(Player.position, transform.position);
if(distance<2)
{
GUI.DrawTexture (new Rect (600, 150, 200, 100), texture, ScaleMode.StretchToFill, false);
if (Input.GetKey (KeyCode.O)) {
Destroy (gameObject.tag="chin");// here i want to destroy object with a tag of "chin", but how
}
}
}
謝謝你這麼多 –
這是固定的:-) @Programmer非常感謝 –
@FarhanAli你是歡迎。如果它對你有幫助,你應該接受它作爲答案。 – Programmer