[英]C# in Unity, SetActive several gameObjects from player entering trigger area
C#和Unity的新手。很好,我整晚都在這里。 我窮過的每個教程都說,將對象從不可見更改為可見,就像將游戲對象設置為開一樣簡單。 但是,當我在此腳本中聲明游戲對象時,Unity給我一個錯誤。 目的是,當輸入觸發器時,將顯示幾個名為“ spawn”的游戲對象。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class collider : MonoBehaviour
{
public gameObject Spawn; // I get error On this line that type is expected,
//not property. It wants a Transform>
private Rigidbody rb;
void Start ()
{
rb = GetComponent<Rigidbody>();
}
void OnTriggerEnter(BoxCollider other)
{
if (other.gameObject.CompareTag("Player"))
{
Spawn.SetActive(true);
}
}
}
gameObject
不是類型,但GameObject
是。
擺脫public gameObject Spawn;
並使用public GameObject Spawn;
聲明一個稱為Spawn
的GameObject
屬性
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.