本文介绍了ThirdPersonController冲突未调用OnTriggerEnter事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour {
public Transform target;
// Update is called once per frame
void Update ()
{
}
private void OnTriggerEnter(Collider col)
{
if (col.gameObject.tag == "Test")
{
this.transform.position = target.position;
}
}
}
我有ThirdPersonController,我希望它与立方体或圆柱体碰撞.该脚本已附加到ThirdPersonController.
I have a ThirdPersonController and i want it to collide with a cube or cylinder.The script is attached to the ThirdPersonController.
我试图添加到圆柱体或立方体中,刚体打开/关闭了使用重力"和运动学",但是什么也没有.没有参加活动.
I tried to add either to the cylinder or the cube Rigidbody turned on/off the Use Gravity and the Is Kinematic but nothing. It's not getting to the event.
推荐答案
ThirdPersonController
使用 CharacterController
和 OnControllerColliderHit
用于不是OnTriggerEnter
.
请注意,必须使用 Move
函数来移动它直接通过其转换才能调用OnControllerColliderHit
.
void OnControllerColliderHit(ControllerColliderHit hit)
{
}
这篇关于ThirdPersonController冲突未调用OnTriggerEnter事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!