C# 对象未触发碰撞器

C# 对象未触发碰撞器,c#,unity3d,virtual-reality,steamvr,C#,Unity3d,Virtual Reality,Steamvr,嗨,我的问题是在Unity中,我是c#的初学者,我的游戏对象没有触发设置在游戏平面上的碰撞器,以便它重置其位置 using System.Collections; using System.Collections.Generic; using UnityEngine; public class BasketballSpawnScript : MonoBehaviour { public Transform respawnPoint; void OnTriggerEnter(

嗨,我的问题是在Unity中,我是c#的初学者,我的游戏对象没有触发设置在游戏平面上的碰撞器,以便它重置其位置

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

public class BasketballSpawnScript : MonoBehaviour
{ 
    public Transform respawnPoint;

    void OnTriggerEnter(Collider other)
    {    
        if (other.gameObject.CompareTag("Basketball"))
        {    
            other.gameObject.transform.position = respawnPoint.position;
        }    
    }
}
此脚本附加到平面,游戏对象被标记为Basketball,当它进入地板的碰撞器时,它应该将其位置转换为原始位置

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

public class BasketballSpawnScript : MonoBehaviour
{ 
    public Transform respawnPoint;

    void OnTriggerEnter(Collider other)
    {    
        if (other.gameObject.CompareTag("Basketball"))
        {    
            other.gameObject.transform.position = respawnPoint.position;
        }    
    }
}
我看不出有什么问题,我能得到一些帮助吗

另外,当其他游戏对象也通过碰撞器时,我会出现这个错误


NullReferenceException:Object reference未设置为对象的实例如果对生成点使用变换,请记住在inspector菜单中设置其值

public Transform respawnPoint;

void OnTriggerEnter(Collider other)
{    
    if (other.CompareTag("Basketball"))
        other.transform.position = respawnPoint.position;
}
否则


我希望它能帮助你。

解决了。在几次谷歌搜索之后,我发现Vector3并使用它来代替transform.position.respawnPoint的最可能的副本
respawnPoint
没有设置。。。
private void OnTriggerEnter(Collider other){

    if(other.gameobject.tag=="Basketball"){

       other.gameobject.transform.position = respawnPoint;
    }
}