So, I’m setting up a trigger system for my enemies on the level, and I’m having some issues.
I have a ship with a box collider and a rigid body.
Then I have an island ( which currently is a sphere) with a collider set to “trigger”
When I move the ship into my island (the sphere) I get the event triggered nicely. (I print out a message).
However, this only happens once.
If I move the ship into the sphere again afterwards, I do not get any events triggered anymore…
Is the trigger deactivated somehow, or what am I doing wrong here? I plan to have movable enemies, which will trigger an action when the ship touches them, but it really does not seem to be working properly
Any insight would be fantastic
Edit: Oh, and the OnTriggerEnter script is set on the Sphere.
If it’s working once and then not happening again it probably means that either
a) You never actually exit the trigger (you can check this by putting a Debug.Log message in a method named OnTriggerStay(Collider other))
b) Your box-collider /rigidbody is not actually entering the trigger… If the rigidbody is attached to a child gameObject of your Ship, and is not Kinematic then it will remain “attached” to it’s parent (it wont move unless explicitly acted on by physics or scripting). If the Ship is not a physics based vehicle, then make sure the rigidbody is set to isKinematic = true;
Well, i have another check on the exit, and the trigger exits fine. But yes, the rigidbody is attached to the child. I have a parent dummy, which is basically empty except for movement controls, then I have the ship which has rigidbody and colliders on. The Is Kinematic is set to true though. Note Im not using forces to move it. Just moving it using regular transforms.
Moving it through regular transforms is fine so long as the rigidbody is kinematic. Can you verify in the editor window that indeed the collider with the rigidbody is indeed entering the trigger the second time. Are there any other colliders (non-triggers) attached to the island?
heh heh I found out the reason for this, and it was pretty silly. I had the collapse button checked in the log window. So when I printed out messages to see if I collided, then I only saw the two first.
Thanks a bunch for the feedback though. Appreciate it a lot! Fantastic community this