错误 CS0029:无法将类型“UnityEngine.GameObject”隐式转换为“字符串”

问题描述 投票:0回答:0

我正在尝试统一检测对游戏对象的触摸,但我无法让它工作,而且我在其他任何地方都看不到它。我明白为什么它不起作用。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

public class toucth : MonoBehaviour
{
    public string touching_qury = "John";
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {

    }
    void OnCollisionEnter(Collision col)
    {
        touching_qury = col.gameObject;
        Debug.Log(touching_qury == "RC_zombie1");
        if(col.gameObject){
            Debug.Log("score + 1");
        }

    }
}
c# unity3d
© www.soinside.com 2019 - 2024. All rights reserved.