Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by gdennis · Dec 11, 2014 at 04:09 PM · cameracamera-movementthird-person

Stop camera from going through walls

I am using the third person controller standard asset from Unity as my playable character. My scene layout looks like a small office, so there are a lot of rooms and a lot of walls. When I run around with my character and I am standing with it's back against the wall, the camera will show the other side of the wall. I tried doing a couple of other solutions I have read on here but none of these seem to work.

The ones i tried are:

  • putting near clipping planes to 0.01

  • http://wiki.unity3d.com/index.php/SmoothFollowWithCameraBumper (attached script to main camera and the 3rd person controller as target)

The second solution (the smoothfollowwithcamerabumper script) is doing what I want (I do have to uncheck the ThirdPersonCamera script component from the 3rd person controller), however turning around in the game is unbearable. one small click on the left arrow will make the character (with camera) INSTANTLY turn around 90° while it used to delay and smoothen out the camera, and the movement is just not right and playable at all. Also rotating 180° by clicking the up/down arrow is just not possible and will make the camera go all wild for some time.

I tried playing a bit with the parameters in the smooth script but this was no solution at all.

Does anyone know why this is happening? Thank you in advance.

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SuperReaper1999 · Dec 11, 2014 at 06:18 PM 0
Share

Does your camera have a collider attached to it so it can actually collide with things?

avatar image Mmmpies · Dec 11, 2014 at 08:40 PM 0
Share

You can also raycast from the camera and make sure the thing you hit is the player. If not the player then have a set of camera points to try until you get one that works. Handy for indoor/caves, well I guess caves are indoor as well!

You can see an example in the S$$anonymous$$lth Tutorial Game: S$$anonymous$$lth Web Player

Run behind a building and the camera swings to a more top down location.

Can't work out the tutorial file locations as the ones that mention the Camera appear to be from a different tutorial but YouTube has plenty of examples and you can still download the asset and view the scripts directly.

avatar image gdennis · Dec 11, 2014 at 10:37 PM 0
Share

@SuperReaper1999 No it does not. However I tried to add a box collider component to the '$$anonymous$$ain Camera' but this does not change anything at all.

@$$anonymous$$mmpies thank you for the idea, but I think that might get a bit too complicated. I will look into it if really nothing else can solve my problem. Thank you!

avatar image Dani-Desa · Jan 30, 2017 at 05:28 PM 0
Share

The second solution was ok for me. Sometimes is not so reliable but after a lot of searching this is the easy one and very straightforward. Thanks for sharing.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by drudiverse · Dec 11, 2014 at 08:30 PM

put a small invisible collider around the camera so that it doesnt go into any other colliders.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image gdennis · Dec 11, 2014 at 10:36 PM 0
Share

I tried doing this but I dont really have any idea how to do it properly, since the way I am trying it, it does not work. Do I just in the inspector select my '$$anonymous$$ain Camera' and then add a component to this? (Physics -> box collider).

I tried this, and it does not work at all.

avatar image Hybrid_Gamez · Aug 03, 2015 at 11:23 AM 0
Share

I think a sphere collider would work better

avatar image
0

Answer by thegdeveloper · Feb 16, 2016 at 06:01 PM

I had the same isue and at first I had a character controller onto the camera and I made the traditions of the camera with the Move() method but this has problems when there is an object between the camera and the playr because the camera can stuck behind. So I have removed the controller and I make a recast from the player to the camera. If it hits something then i move the camera forward of the position that there is a collision. Another approach is to keep the character controller and make a ray cast from the camera towards the player. If it hits something use disable the collider and the camera does not stuck but sometimes you see thing through the mess. So I have chosen the approach that I mention earlier. play with whatever solution does the job for you

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Third person camera aim 0 Answers

Moving 3rd person player relative to orbiting camera 1 Answer

Camera movement in a Third Person Shooter Game 2 Answers

I only rotated X, but Y and Z are shifting as well when I play the game. 1 Answer

How can I mimic this game's camera in Unity? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges