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