0
\$\begingroup\$

I do not want to use the physics engine, I only want the collider to detect when they have entered into another collider, then I want to handle what happens to the objects.

Moving static colliders (colliders that do not attach to a rigidbody) around has a penalty, so how would I accomplish this without incurring a penalty for moving colliders around that do not attach to a rigidbody?

I could use a Kinematic Rigidbody Collider for this, but this seems kind of hacky since they are meant to be used in conjunction with Rigidbody Colliders (at least thats what their intention seems like from the manual). I have also looked into CharacterController, it says it "does not make use of Rigidbody physics", but it does not say how the physic system treats it which would come with a penalty if the physic system sees it as a static collider (as it uses a capsule collider with no rigidbody). I tested to see if it did have a penalty, but unless stated how it works within the physics system, it is just speculation which could lead to undesired results.

Other than a Kinematic Rigidbody Collider or CharacterController, is there any way to accomplish this in unity?

\$\endgroup\$
1
  • \$\begingroup\$ Presumably you considered just using regular rigidbodies with colliders set as triggers, so their movement is not affected by collisions? \$\endgroup\$ – DMGregory Dec 15 '20 at 4:12
0
\$\begingroup\$

There seems to be another approach with using LayerMasks in Unity.

I'm not sure how it works yet but you may want to take a look at this answer.

\$\endgroup\$
0
\$\begingroup\$

Yes, Unity has it own intersect method.

Attach an collider to your gameobjects that should check for collision. You do not have to use a Rigidbody for Bounds.Intersects. Also it works for both 2D and 3D

//If the first GameObject's Bounds enters the second GameObject's Bounds, output the message
if (collider.bounds.Intersects(collider2.bounds))
{
   Debug.Log("Bounds intersecting");
}

I'll give you a link to description

https://docs.unity3d.com/ScriptReference/Bounds.Intersects.html

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.