OnCollisionEnter Works for Objects, but not Player

Hi all, Im trying to make a simple script that moves Objects and the Player to a ‘respawn’ location if they happen to fall through the map, this works flawlessly for GameObjects, but wont recognize the Player what so ever, I ended up adding a OnCollisionStay & OnCollisionExit to try see what was going on, but It doesnt seem to recognize the player at all, The play can just walk around on the Collider but doesnt trigger any events. Obviously I’m doing something wrong, I just can’t figure it out. My guess is that Character Colliders dont work the same way Box/Sphere ect Colliders work, is there something I can add tyo my code that will also work for CharacterColliders?

GameObjects:
alt text

Player:
alt text

Code:

using UnityEngine;

public class lostItemReturn : MonoBehaviour
{

    [SerializeField] Transform returnTele;

    private void OnCollisionEnter(Collision other)
    {
        if (other.collider.CompareTag("Player"))
        {//No Log is printed
            Debug.Log("Attempting To Teleport Player");
        }
        
        Rigidbody rig = other.gameObject.GetComponent<Rigidbody>();
        rig.isKinematic = true;
        other.transform.position = returnTele.position;
        other.transform.Rotate(0,0,0);
        rig.isKinematic = false;
    }
//Added to attempt to fix, thinking it may have missed the frame where the character entered.
    private void OnCollisionStay(Collision other)
    {
        Rigidbody rig = other.gameObject.GetComponent<Rigidbody>();
        rig.isKinematic = true;
        other.transform.position = returnTele.position;
        other.transform.Rotate(0, 0, 0);
        rig.isKinematic = false;
    }
//Added to see if jumping in and out of the collider would work
    private void OnCollisionExit(Collision other)
    {
        Rigidbody rig = other.gameObject.GetComponent<Rigidbody>();
        rig.isKinematic = true;
        other.transform.position = returnTele.position;
        other.transform.Rotate(0, 0, 0);
        rig.isKinematic = false;
    }
}
  1. (edited) Add CharacterController.OnControllerColliderHit(ControllerColliderHit):

    void OnControllerColliderHit(ControllerColliderHit hit) => TeleportBack(hit.transform);
    void OnCollisionEnter(Collision other) => TeleportBack(other.transform);

    void TeleportBack(Transform trans)
    {
    // Your code
    }

  2. If your object is a trigger inside its Collider Options in the inspector, use OnTrigger Enter/Stay/Exit.

  3. Make sure either of the objects consists of a Rigidbody.

  4. Check if the rigidbody detects any Collisions at all:

    void OnCollisionEnter(Collision other) => Debug.Log(other);

  5. Make sure your script is attached to the object/zone that the players falls upon.

  6. Make sure that the GameObject with the tag “Player” is on the GameObject that also has the Collider (and possible Rigidbody)

  7. Try making sure it’s the player so it doesn’t give errors if it’s not the player by doing:

    if(other.transform.tag != “Player”) return;
    Let me know your fix if you want to share it, otherwise let me know if it didn’t work. Good luck:pray:

So I tried two ways. Both are Working fine.

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

public class RespawnPlayer : MonoBehaviour
{

    [SerializeField] GameObject spawnPoint;

    // Start is called before the first frame update
    void Start()
    {
        spawnPoint = GameObject.FindGameObjectWithTag("Spawn");
    }
    
    // Update is called once per frame
    void Update()
    {
        //If the player is falling, respawn.
        if(transform.position.y < -1f)
        {
            transform.position = spawnPoint.transform.position;
        }
    }

    private void OnCollisionEnter(Collision collision)
    {
        //if the player collieds with the Zone under the Box, respawn
        if (collision.gameObject.tag.Equals("Respawn"))
        {
            transform.position = spawnPoint.transform.position;
        }
    }

}

the Character has a Rb, character controller and a Collieder attached.

Hope this will fix your problem.