Home > other >  a script of mine doesnt work(on collision enter)
a script of mine doesnt work(on collision enter)

Time:07-10

OnCollisionEnter does not work here is the script:

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

public class Collision : MonoBehaviour
{
    private void OnCollisionEnter(UnityEngine.Collision other)
    {
        if(other.gameObject.tag == "Wrong")
        {
           print("test");
        }
    }
}

both of their BoxColliders "isTrigger" is set to false(the player is a capsule does it matter?) the player has a rigidbody with "isKinematic" set to True(the player is using Character Controller as the movement does it matter?) idk what to do the platform is 3D help plz

CodePudding user response:

By default, collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached. So maybe that's why your OnCollisionEnter event isn't firing.

CodePudding user response:

Your collision isn't firing because none of them have a non-kinematic rigidbody attatched. Try checking all the constraints to replicate Is Kinematic in the rigidbody. I tested it in Unity and it works. Rigidbody constraints image

  • Related