Search Unity

Camera stretches objects that are attached to it

Discussion in 'Physics' started by DBalNk, Jan 21, 2020.

  1. DBalNk

    DBalNk

    Joined:
    Jul 29, 2017
    Posts:
    1
    I've decided to create a horror game but I've been having this bug since I started. Once I attach my flashlight (.FBX) model onto my fps camera when I look around it starts to do some weird stretching of the model, In the scene tab it looks normal but in the game tab, a whole different thing happens. Any ideas?
     

    Attached Files:

  2. devotid

    devotid

    Joined:
    Nov 14, 2011
    Posts:
    445
    The parent object that you are nesting the flashlight to has a non uniform Scale? (Its not 1,1,1). If you are parenting things to your player controller make sure the item you are "Attaching" it too is scaled to 1,1,1. If not when you move around it will scale the flashlight to some funny sizes.

    Another work around is to scale the flashlight once after parenting the object if it is in real time.

    Kevin
     
  3. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    To me, that looks like the standard perspective distortion (note that the sun is also distorted). That happens when using a wide field of view, and it's highly noticeable in the objects that are closer to the camera. Reducing the field of view in the camera should help (Camera.fieldOfView), but then you might not get the "first person flashlight" effect you're expecting.

    Games use a variety of tricks to overcome this. Typically, the scene is rendered using one camera and the first person objects (weapon, hands, flashlight, etc) are rendered with a different camera. This second camera doesn't render the background (Camera.clearFlags = CameraClearFlags.Nothing), and is displayed on top of the scene camera (Camera.depth). This also prevents artifacts such as the first person objects visually intersecting with the scenario.
     
  4. noahmurrant

    noahmurrant

    Joined:
    Jan 21, 2021
    Posts:
    1
    devotid is right, but as long as every thing is uniformly scaled it wont stretch, x = y = z, doesn't matter what they are on either object and long as they're both scaled uniformly