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. Dismiss Notice

WheelCollider WheelHit Issue, please help!

Discussion in 'Editor & General Support' started by concretegames, Feb 2, 2021.

  1. concretegames

    concretegames

    Joined:
    Dec 2, 2016
    Posts:
    15
    WheelCollider WheelHit Behaviour
    Hey guys! My project is a bit complicated and messed up, so I started a new one to see if I can reproduce the problem and yes, fresh new start, and facing same trouble. Here we go.

    Fresh new Project, with main camera and light in it. Added a plane, scaled it to 100,0,100. Added a cube to wich i added Rigidbody with mass of 800. To it i added 4 WheelColliders, wich i positioned about right for a "car". Then i made this short script with wich i want to see the values of the fwd and sideways slip of all the WheelColliders, separately.


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class ColliderTest : MonoBehaviour
    6. {
    7.     public WheelCollider WheelFL;
    8.     public WheelCollider WheelFR;
    9.     public WheelCollider WheelRL;
    10.     public WheelCollider WheelRR;
    11.  
    12.     [Space]
    13.  
    14.  
    15.     public float Wheel_FL_SSkid;
    16.     public float Wheel_FR_SSkid;
    17.     public float Wheel_RL_SSkid;
    18.     public float Wheel_RR_SSkid;
    19.     [Space]
    20.  
    21.  
    22.     public float Wheel_FL_FSkid;
    23.     public float Wheel_FR_FSkid;
    24.     public float Wheel_RL_FSkid;
    25.     public float Wheel_RR_FSkid;
    26.  
    27.  
    28.      void Update()
    29.     {
    30.         WheelFL.GetGroundHit(out WheelHit FL_HIT);
    31.         WheelFR.GetGroundHit(out WheelHit FR_HIT);
    32.         WheelRL.GetGroundHit(out WheelHit RL_HIT);
    33.         WheelRR.GetGroundHit(out WheelHit RR_HIT);
    34.  
    35.         Wheel_FL_SSkid = FL_HIT.sidewaysSlip;
    36.         Wheel_FR_SSkid = FR_HIT.sidewaysSlip;
    37.         Wheel_RL_SSkid = RL_HIT.sidewaysSlip;
    38.         Wheel_RL_SSkid = RR_HIT.sidewaysSlip;
    39.  
    40.         Wheel_FL_FSkid = FL_HIT.forwardSlip;
    41.         Wheel_FR_FSkid = FR_HIT.forwardSlip;
    42.         Wheel_RL_FSkid = RL_HIT.forwardSlip;
    43.         Wheel_RL_FSkid = RR_HIT.forwardSlip;
    44.     }
    45. }
    46.  

    I get for the first 3 wheel colliders the values in realtime, but the forth one always stays 0, no matter how i arrange or rename the wheelcolliders.

    Thank you!
    And please pardon my english-spelling abillities!,
     
  2. concretegames

    concretegames

    Joined:
    Dec 2, 2016
    Posts:
    15
    Okay, after about 2 hours of fighting with the script, I have found that simply renaming the floats to use any name but not using "_" in their names, will make it work...why is that happening ?