ThirdPersonController collision not calling OnTriggerEnter event

后端 未结 2 1401
醉话见心
醉话见心 2021-01-28 15:45
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Test : MonoBehaviour {

    public Transform target;

    // Update is calle         


        
相关标签:
2条回答
  • 2021-01-28 16:14

    Every thing is correct but the thing wrong here is you are changing the position of the object which is colliding with a second object , but the thing id the thing is the collider is already there..... As it's alternative try to print any statement when collision happens like this

    private  void OnTriggerEnter(Collider other)
    {
      if (other.tag==your_tag)
    
    {
    print("message");
    }
    }
    
    0 讨论(0)
  • 2021-01-28 16:36

    ThirdPersonController uses CharacterController and OnControllerColliderHit is used for that not OnTriggerEnter.

    Note that you must move it with the Move function not directly by its transform in order for OnControllerColliderHit to be called.

    void OnControllerColliderHit(ControllerColliderHit hit)
    {
    
    }
    
    0 讨论(0)
提交回复
热议问题