I’m trying to understand why my colliders are not working. I have 2 objects in my scene, a players sword and a floating enemy. See attached picture for the game object configurations. These two objects are colliding, and the layer for each is configured to collide in my project physics setup. Yet I’m not seeing any OnTriggerEnter collision event.
From the docs (Unity - Manual: Introduction to collision) I need at least one RigidBody, which I have. I don’t want to simulate physics for these collisions, I just want to detect the collision and then handle it myself with character controllers and such.
Can anyone help me understand why I’m not getting a collision event here?
interesting. So if I don’t want any physics simulation besides collision detection, what is the correct set of components for each object? I want the objects to be able to pass through each other (one is a player sword so I don’t want the swing to stop when it hits an enemy). I also don’t want any physics interactions like the objects pushing each other, I want to handle this myself with character controllers
whats weird is my player character is set up the exact same, with no rigid body and an IsTrigger box collider. Yet the enemies box collider interacting with the players will result in OnTriggerEnter from being called
I was really surprised to see this, so I checked it out. It’s wrong [Edit: misleading, not wrong:)]!
& it contradicts the table at the bottom here: https://docs.unity3d.com/Manual/collider-types-interaction.html
In my test scene my dynamic rigidbody trigger cube notices when it hits my static trigger cube, and the static notices when it is being hit. Works fine for kinematic too. @habahut I sometimes get caught out with where I put my OnTriggerEnter script, I can never remember if it needs to be on the same GameObject that contains the Rigidbody, or the one that contains the collider (I don’t think it works if it’s somewhere else entirely). From your screenshot, it doesn’t look like you have a script on either of the collider objects.
The test I did just now, I had everything in the root of both objects for simplicity.
oh yes you are correct! I needed the actual collider to be parented to the user and not the weapon itself, so that it wouldn’t move around with the attack animation. This meant the trigger was happening on this sub object and not the weapon. So I created a prefab with a simple script that calls back to the weapon for the trigger.