Search Unity

How to collision detection with code

Discussion in 'Editor & General Support' started by Rachan, Aug 21, 2020.

  1. Rachan

    Rachan

    Joined:
    Dec 3, 2012
    Posts:
    781
    Hi There!

    How to collision detection with only code But without using OnCollisionEnter or any build-in function
    I just wanted to know how to check a collision hit with a collider by script in C#
    such as (collisionA collision with collisionB )

    I had used to created a basic collision with code by use it's position and it's hit distance
    but! if it's has a big collision it need to be closed, so it not work like I need.

    I don't want to use a build-in function like OnCollistionEnter or OnTriggerEnter or any function.

    Thanks!!!
     
  2. TimmyTheTerrible

    TimmyTheTerrible

    Joined:
    Feb 18, 2017
    Posts:
    186
    You would have to use the various physics functions. Physics.Raycast, Physics.SphereCast(), etc.
     
    Rachan likes this.
  3. Rachan

    Rachan

    Joined:
    Dec 3, 2012
    Posts:
    781
    Wow Thank you very much I can made it now!!!
     
  4. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,639