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
1
Question by KBWork1 · Jun 13, 2013 at 08:42 AM · cameracollisionmesh

how to prevent camera from moving through meshes

How do you set up the camera or scene or mesh objects to prevent a camera from moving through the meshes? Would be better if the camera position is prevented from passing through mesh volumes. Thanks, Kevin.

Comment
Add comment · Show 2
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 Graham-Dunnett ♦♦ · Jun 13, 2013 at 10:18 AM 0
Share

Use collision detection.

avatar image KBWork1 · Jun 13, 2013 at 10:23 AM 0
Share

Can collision detection be added as a component to a camera?

1 Reply

· Add your reply
  • Sort: 
avatar image
18
Best Answer

Answer by bartleycollin · Jun 13, 2013 at 05:00 PM

You could do 2 things.

  1. If you meant that when the camera bumps up against a wall, you can see through the wall, then do this. Select the camera, go the inspector and set the near clipping planes to 0.1

  2. If you meant that you wanted the camera to be able to bump against a wall, without actually going through the wall, then create an empty game object. Give the empty a box collider, and set it to the exact location of the camera. Finally set the empty object as the Camera's parent. Now when you move you Empty, it moves the camera, and it won't go through the walls. Hope this helped!

Comment
Add comment · Show 10 · 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 luckynamal · May 13, 2016 at 12:18 PM 0
Share

You are awesome.. Thank you so so so much......

avatar image dika_dk · Jul 13, 2017 at 09:00 PM 0
Share

Great solutions, thanks!

avatar image Harinezumi · Aug 19, 2017 at 05:42 PM 0
Share

This solution does not work anymore. You need a Rigidbody on the parent as well (turn off gravity) and move it with Rigidbody.$$anonymous$$ove()

avatar image cmcosby · Mar 26, 2018 at 12:57 AM 0
Share

Dude, #2 was a brilliant solution

avatar image buddyroach · Sep 03, 2018 at 09:53 PM 0
Share

This kinda works but it causes problems. If the camera is in third person, once the camera hits a wall, it prevents the player from moving further back. But when moving the mouse camera direction while moving, you can get the camera to clip anyway. And when the camera collider collides into another object, Unity crashes. Anyone have a better solution? Like maybe the camera will move closer to the player when squished between the player and the wall and retract back when that space h

avatar image myzzie buddyroach · Sep 03, 2018 at 10:02 PM 0
Share

Cast 4 rays from player to camera's near clipping plane. If the rays hit an obstacle, move the camera towards player until no collision detected. Can do a lot with this but that's a rough idea of it.

avatar image buddyroach myzzie · Sep 16, 2018 at 09:30 AM 0
Share

oh nice. Thats a good idea. Thanks!

Show more comments

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

27 People are following this question.

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

Related Questions

why camera does not recognize the collision? 1 Answer

Leap motion: how to pickup a custom mesh 0 Answers

Mesh not showing in camera 3 Answers

move camera when it collides with a trigger 1 Answer

Having an array of points(vector2), how do I create a 2d terrain? (new to unity) 2 Answers


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