Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

WheelCollider.GetGroundHit(out hit) - value hit.point is wrong!

Discussion in 'Windows' started by Nolex, Aug 31, 2013.

  1. Nolex

    Nolex

    Joined:
    Dec 10, 2010
    Posts:
    116
    My game works successful on android, ios, webplayer, but in wp8 I had a bug with WheelCollider.GetGroundHit(out hit).

    Value of hit.point on WP8 is wrong and always - (1.0, 0.0, 1.0)... I count not make suspension system.

    Code (csharp):
    1.             Vector3 lp = w.transform.localPosition;
    2.             if (col.GetGroundHit(out hit)) {
    3.                
    4.                 lp.y -= Vector3.Dot(w.transform.position - hit.point, mytrans.up) - col.radius;
    5.  
    6.                 w.floorcontact = true;
    7.             }
    8.             else {
    9.                 lp.y = w.startPos.y - suspensionDistance;
    10.                 w.floorcontact = false;
    11.                
    12.             }
    13.            
    14.             w.transform.localPosition = lp;
    15.  
    Thanks!

    -- Nolex
     
    Last edited: Sep 1, 2013
  2. Nolex

    Nolex

    Joined:
    Dec 10, 2010
    Posts:
    116
    I solved this by changing GetGroundHit to Physics.Raycast

    Code (csharp):
    1. RaycastHit hit;
    2.  
    3. if (Physics.Raycast(col.transform.position, -mytrans.up, out hit, col.radius + 0.2f, 1 << 10)) {
    4.      blabla;
    5. }
    6.  
     
  3. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,948
    What version of Unity do you use?
     
  4. Nolex

    Nolex

    Joined:
    Dec 10, 2010
    Posts:
    116
    4.2.0
     
  5. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,948
    Please submit a bug report with simple repro project.

    Thank you