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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Wheel colliders collision detection

Discussion in 'Physics' started by glad, Sep 7, 2018.

  1. glad

    glad

    Joined:
    May 10, 2014
    Posts:
    76
    Hello.

    I created the following:
    upload_2018-9-7_19-9-12.png

    Root(rigidbody with 2 wheel colliders).

    I attached this script to the root:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class CollisionTest : MonoBehaviour
    5. {
    6.     private void OnCollisionEnter(Collision other)
    7.     {
    8.         Debug.Log("OnCollisionEnter (" + other.gameObject + ")");
    9.     }
    10.  
    11.     private void OnCollisionExit(Collision other)
    12.     {
    13.         Debug.Log("OnCollisionExit (" + other.gameObject + ")");
    14.     }
    15. }
    So.. When running the scene they are falling, bumping away and.. no debug log. No collision detected.

    What am I doing wrong ?
     
  2. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
  3. glad

    glad

    Joined:
    May 10, 2014
    Posts:
    76
  4. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    You will have a hit variable and the ref return from that function will fill in that variable. So you pre allocate it. It is not an expensive call.
     
    glad likes this.
  5. glad

    glad

    Joined:
    May 10, 2014
    Posts:
    76
    Thank you!