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. Dismiss Notice

Camera is clipping underneath terrain

Discussion in 'Editor & General Support' started by junctionboss, Oct 3, 2014.

  1. junctionboss

    junctionboss

    Joined:
    May 11, 2014
    Posts:
    227
    Using beta assets with ethan 3rd person character and when I am on slopes and I rotate camera, I can see terrain underneath me as I rotate camera view backwards, is there a way to stop this ? I am standing on imported 3d mesh with unity terrain underneath it.

    Thx
    jb
     
  2. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,169
    There are multiple ways to handle this depending on your camera. Since you are third person, the best thing to do is to implement collision detection as part of your camera movement. Use a sphere with a radius a little larger than the near clipping plane on your camera. You'll need to do a collision test from your camera target to your cameras hypothetical position using this sphere, and then place the actual camera location at that spot.
     
  3. junctionboss

    junctionboss

    Joined:
    May 11, 2014
    Posts:
    227
    HI,

    Im not very skilled atm with programming nor the things You are suggesting. I can't even get the 'collision sphere' around the character without character going into crawl position instead of walking, or floating in mid air, assuming you meant collsion sphere from unity menu ?

    Is there some tutorial you can point me to ? Sorry, I do use unity but Im a artist first and foremost and what you suggest ( the later part of it anyway) is beyond my skillset. Oh btw camera near plane is 0.21 so making this sphere, if I have created it right is going to be pretty small does that sound correct ??

    Thank you very much for responding ;)

    cheers
    jb
     
  4. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,169
    No, sorry, thats not what I meant at all. Basically you would use a "RayCast" or "SphereCast" function from your camera target to the cameras preferred location.

    I recommend to just buy a camera script with collision detection like this one:

    https://www.assetstore.unity3d.com/en/#!/content/18760

    if you need something right away. Otherwise, I suggest going through a beginner C# tutorial somewhere, and then taking on the massive tutorial set here: http://www.burgzergarcade.com/hack-slash-rpg-unity3d-game-engine-tutorial
     
  5. junctionboss

    junctionboss

    Joined:
    May 11, 2014
    Posts:
    227
    Ok thx ;)(

    cheers
    jb
     
  6. Everret

    Everret

    Joined:
    Dec 30, 2016
    Posts:
    6
    just ad a sphere collider and a rigid body to the camera. Turn the gravity off on the rigid body
     
  7. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,169
    My how Unity has changed in the 6 years since this was asked. I bet he has solved it since then. Yet even then this wouldn't solve the problem, unless you used physics to move the camera around.
     
    Joe1512 likes this.