Search Unity

Raycast/Mouse Position bug in 2019.2

Discussion in 'Physics' started by PhoenixAdvanced, Sep 2, 2019.

  1. PhoenixAdvanced

    PhoenixAdvanced

    Joined:
    Sep 30, 2016
    Posts:
    316
    Hello,

    I have just finished porting my project from 2019.1 to 2019.2.

    Everything seems to have gone ok, except for one annoying bug.

    In 2019.2 (and only 2019.2) the raycasts from my player camera are offset by a substantial amount.

    I have used debug.drawray to test this, and the ray cast is originating from the center of the camera, as it should, so, the problem must be with Input.moustpostion returning incorrect values?

    Has something changed in the raycast system, or input,mouseposition in 2019.2?

    This is my code, it's basically the same as the example code for raycasting:

    Code (CSharp):
    1.  
    2.  
    3.            Camera cam = mcam; //Player Camera
    4.             Ray eye = cam.ScreenPointToRay(Input.mousePosition);
    5.                      
    6.             Debug.DrawLine(eye.origin, eye.origin + eye.direction * 100, Color.green,5); //Shows correct origin and direction for the ray, but it is pointing at a point below where it should
    7.  
    8.             if (Physics.Raycast(eye, out hit, range))
    9.  
    10.  
    Like I said, this is simple stuff, and this code was working fine for over a year, since I wrote it. I can't see why the port to 2019.2 would suddenly break something.
     
  2. PhoenixAdvanced

    PhoenixAdvanced

    Joined:
    Sep 30, 2016
    Posts:
    316
    I have discovered that changing my editor window to 1024x1024 resolution seems to mostly fix this issue. I still don't know what it causing it.
     
  3. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    I expirence some wierdness in 2019.1.7 too, i havn't time to investigate though..
     
    Last edited: Sep 3, 2019
  4. PhoenixAdvanced

    PhoenixAdvanced

    Joined:
    Sep 30, 2016
    Posts:
    316
    I found some bug tracker reports that said that this was a known issue in 2017, but that it was fixed?
     
  5. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    Oh, sorry, miss typed.

    I meant 2019.1.7f.
     
  6. PhoenixAdvanced

    PhoenixAdvanced

    Joined:
    Sep 30, 2016
    Posts:
    316
    Oh I see. Well in that case, there could still be a bug in unity?

    I was using 2019.1.1 I think? So it could have bee introduced in a later build.