Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Collision without "physics"

Discussion in 'Physics' started by AntP, Jan 10, 2018.

  1. AntP

    AntP

    Joined:
    May 1, 2013
    Posts:
    1
    This question has been asked in a few forms over the years but the answers vary and there doesn't seem to be any common understanding of the "right" way to do this.

    Suppose you have a 3D game and you want to prevent objects clipping through one another but otherwise don't need any physics simulation.

    Is there a canonically correct way to approach this? If not, what are the pros and cons of using RigidBody vs. scripting the collision detection manually?
     
    BrandyStarbrite likes this.
  2. KeithKong

    KeithKong

    Joined:
    May 31, 2015
    Posts:
    73
    Static objects don't collide with each other, neither do kinematic rigidbodies.

    So every solution to this will involve a trigger collider (the only non-physical way to detect collisions between two objects) and thus it will require a rigidbody (trigger colliders cannot be added to static objects).

    The only choice is whether to use kinematic or physical rigidbodies. This really comes down to if you prefer applying forces which involve realistic movement like momentum, or lerp movements which allow you to specify the exact motion on a custom frame by frame basis. Without any non-trigger colliders, a physical rigidbody is otherwise the same as a kinematic one.
     
  3. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I do non physical collisions in Unity all the time using ComputePenetration. Works perfect. Its because I needed to work with Physx colliders as normal but also do my own thing.
     
    iscf likes this.