Search Unity

Obj on Character Controller is strangely deforming

Discussion in 'Physics' started by Einfach_Tobi, May 29, 2016.

  1. Einfach_Tobi

    Einfach_Tobi

    Joined:
    May 29, 2016
    Posts:
    13
    Hi! (I'm not quite sure if this thread is posted under the right topic)

    I have the following problem. I added my flashlight.obj I created in blender to my Standard Asset Character Controller. I want it to follow the camera so it's always in the bottom left corner. The problem is that whenever I look up or down, the flashlight gets stretched in a very strange way and I have no idea on how to fix that.

    Thank you for helping me. unity bugnormal.jpg unity bugstretch.jpg unitybug2.png
     
    Last edited: May 31, 2016
  2. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    Can you please create an image with sunlight added, becuase its very dark
     
  3. Einfach_Tobi

    Einfach_Tobi

    Joined:
    May 29, 2016
    Posts:
    13
    Yeah sure, sorry, didn't think about that. unitybug2.png
     
  4. Hyblademin

    Hyblademin

    Joined:
    Oct 14, 2013
    Posts:
    725
    Does the camera that renders your flashlight have a different FOV than the main camera or something? Not sure if this would effect it, but maybe if your vertical rotation is in some way off, mismatched fields of view could cause this.
     
  5. Einfach_Tobi

    Einfach_Tobi

    Joined:
    May 29, 2016
    Posts:
    13
    I'm not quite sure if I got that right. This would require two cameras to be there, wouldn't it? But the whole scene only has that one camera placed on my controller. "but maybe if your vertical rotation is in some way off, mismatched fields of view could cause this." - Do you know on how to fix that?
    I added the flashlight as a child to the camera which is already moved by the controller script. I thought it would work like that.
     
  6. Hyblademin

    Hyblademin

    Joined:
    Oct 14, 2013
    Posts:
    725
    @Tobi_Donni

    You're correct; if you're only using one camera, then my guess is wrong.

    Are you sure nothing is rotating your flashlight independently of its parent object?

    I'm also wondering if you could post of .gif of the effect. Maybe visualizing it will reveal something.
     
  7. Einfach_Tobi

    Einfach_Tobi

    Joined:
    May 29, 2016
    Posts:
    13
    I'm not sure but I think that's the case.

    I can make a .gif but the quality is not that good, sry.
    (UPDATE: Okay, it wont let me upload the file... it says "The uploaded file is too large for the server to process." even though it isn't! I resized it so many times and it only has a size of 2MB...
    There you go: http://prntscr.com/bdj4gb )
     
    Last edited: Jun 7, 2016
  8. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    Could you check the scene view for me? Did the one there get longer too?
     
  9. Einfach_Tobi

    Einfach_Tobi

    Joined:
    May 29, 2016
    Posts:
    13
    Never had the idea on checking that. Yeah it did. So it's not one of the image effects.
     
  10. Hyblademin

    Hyblademin

    Joined:
    Oct 14, 2013
    Posts:
    725
    Have you checked the flashlight's scale when it does that? It really looks like its scale is being changed by something.
     
  11. Evil_Moo

    Evil_Moo

    Joined:
    Jan 23, 2014
    Posts:
    25
    It looks to me like it is parented to something with non-uniform scale. When the child rotates, it aligns itself with a different axis (in this case, looking up or down will align with the Y axis) and if that axis has a different scale than the others, the child will stretch to match.

    You can reproduce this effect easily by creating an empty object with scale (1,2,1), adding a cube as a child of that object and rotating the cube around x or z.
     
    Einfach_Tobi and eses like this.
  12. Einfach_Tobi

    Einfach_Tobi

    Joined:
    May 29, 2016
    Posts:
    13
    Thank you! I think, that's it! But I actually have no idea, how to fix that. I appreciate your help!
     
  13. Einfach_Tobi

    Einfach_Tobi

    Joined:
    May 29, 2016
    Posts:
    13
    Yeah, the scale does change.
     
  14. Evil_Moo

    Evil_Moo

    Joined:
    Jan 23, 2014
    Posts:
    25
    The fix would be to keep every object in your character's hierarchy, down to the object that rotates, at a uniform scale (keeping things at (1,1,1) tends to be easiest, but as long as the x, y and z are the same on each object, it should work).

    If you want to change the size of your character controller you should change the height or radius parameters on the character controller component itself, not scale the transform.

    If there is something that you absolutely need to be non-uniform scale, then you could keep it in a separate 'branch' of your hierarchy to the rotating object, so it doesn't affect it.
     
    Einfach_Tobi likes this.