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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Camera not viewing correctly

Discussion in 'General Graphics' started by DanSingh, Jun 1, 2016.

  1. DanSingh

    DanSingh

    Joined:
    Feb 5, 2015
    Posts:
    98
    Greetings,
    In my scene view my camera seems to be in the correct perspective however in the actually game it seems to be off and this is crucial to my game because the raycaat might seem off but in reality its not. Please help.
    Thanks
     

    Attached Files:

    Last edited: Jun 1, 2016
  2. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    What's wrong about it? You say the camera is "off a bit", but I can't tell from the screenshot or post what's wrong or what it should look like.

    Could you explain the problem that is happening because the camera is off a bit? Could you also screenshot with your camera selected so I can see it in the inspector?
     
  3. DanSingh

    DanSingh

    Joined:
    Feb 5, 2015
    Posts:
    98
    As you can see in the Game the gun doesn't seem to be point at the cube, however in the Scene it is point at the cube, and my raycast picks up the cube, but in the Game it doesn't seem like the gun is point at the cube.
     

    Attached Files:

  4. DanSingh

    DanSingh

    Joined:
    Feb 5, 2015
    Posts:
    98
    However I might think that maybe its the pivot point, I'm not sure.
     
  5. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    It's because of the perspective of the camera. With a perspective camera, everything is stretched more at the sides, and objects that are closer appear larger than objects that are farther.

    This is much like real life: Touch your finger to an object, obviously you're pointing at that object. Now back up, but keep your finger pointing. Even if you're still pointing at that object, it might not look like you are because of your perspective.

    If you want your gun to line up perfectly with where is will shoot, you would have to put the muzzle of the gun in the exact center of the screen. That's why the gun moves to the center of the screen when you aim down the sights in any shooter game.
     
  6. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    If the perspective is too much, you can reduce the "FoV" on your camera to make things a bit more flat and appear to line up better.
     
  7. DanSingh

    DanSingh

    Joined:
    Feb 5, 2015
    Posts:
    98
    I've tried that to it wont work.
     
  8. DanSingh

    DanSingh

    Joined:
    Feb 5, 2015
    Posts:
    98
    I've figured it out, I have the camera and the gun rotating at the same angle and speed, and they have an offset to each other, thus I must compensate for this. I think I've got it.