【发布时间】:2020-08-23 03:35:32
【问题描述】:
当玩家杀死敌人时,我需要给他弹药。我正在尝试使用 GetComponent,但我不断收到错误“:错误 CS0428:无法将方法组 'GetComponent' 转换为非委托类型 'thro'。您打算调用该方法吗?”在这一行:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class collision : MonoBehaviour
{
public int cardno = 13;
public GameObject deck;
thro deck_script;
void OnCollisionEnter (Collision cl)
{
if(cl.collider.tag == "iscard")
{
int cardran = Random.Range(1,14);
Debug.Log(cardran);
*deck_script = deck.GetComponent<thro>;*
if (cardran == cardno)
{
Destroy(gameObject);
Debug.Log("kil");
}
}
}
}
【问题讨论】: