Search Unity

Mouse position gets more "off" when resolution changes

Discussion in 'Scripting' started by sickb0y247, Apr 18, 2015.

  1. sickb0y247

    sickb0y247

    Joined:
    May 29, 2014
    Posts:
    54
    Hello Unity peeps. Can someone please explain what is happening here to me and possibly a solution? Here's a video showing what I'm talking about. As I change resolution my bullets are shooting further and further from the cursor. In Free Aspect it works perfectly though. Any help would be much appreciated:

     
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,537
    Well... that depends on how you coded it to choose the direction that it shoots.

    I honestly have NO idea what your code is, and this video gives me no clue as to how it's done. Especially since I don't even know what you expect it to do.
     
  3. sickb0y247

    sickb0y247

    Joined:
    May 29, 2014
    Posts:
    54
    I'm casting a ray using ScreenPointToRay. Then I get the hit.point and I fire a bullet from the muzzle of the gun to the hit point of the ray. On the free aspect it shoot directly where the crosshair is but when I change resolutions it fires further from the crosshair than it should. 16:9 resolution is slightly off and as I go lower and lower on resolution it's more noticeably off target of the crosshair
     
  4. sickb0y247

    sickb0y247

    Joined:
    May 29, 2014
    Posts:
    54
    I put the mouse position into the screenpointtoray and the crosshair is just the mouse's cursor graphic so I don't understand why both of these aren't one in the same and seem to differ when the resolution is changed
     
  5. sickb0y247

    sickb0y247

    Joined:
    May 29, 2014
    Posts:
    54
    I got it working. Still not sure why it was causing problems but it had to be something about that crosshair image because I switched to a different cursor and it works just fine