Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Shykeas · Apr 11, 2015 at 09:58 AM · cameracollisiongameobjectcollider

How to stop Camera from going into colliders

I've looked all over this amazing website for the answer, BUT I CAN'T FIGURE IT OUT! So, I've seen it worked for some people but not me. Here's what I'm using:

The DEFAULT ThirdPersonCamera from the ThirdPersonController which is the Construction guy that came with the older version of Unity. (like Unity 3. ._.) So putting the Near Clipping to like 0.1 didn't work. So I'm assuming it's the script. Which tell my Main Camera to go the axis it goes into... You know? Whether Mesh/etc. Colliders are in the way or not.

So here's the three script I have on my Camera:

Mouse Orbit var Target (Transform) //I already have my Game Object it wants to target in there var Distance : 5 var XSpeed : 250 Var YSpeed : 150 var YMin Limit : -20 var YMax Limit : 80

Smooth Follow var Target : (Transform) //Same as the first one var Distance : 10 var Height : 5 var Height Damping : 2 var Rotation Damping : 3

Smooth Look At var Target: (Transform) //Need I say more? var Damping : 6 var Smooth : Checked Box

What I want specifically is for the Camera to be similar to a legit OBJECT that can't go through walls with Colliders. Or ANYTHING with colliders.

Now BEFORE you insist I just get an Empty object that is a legit collider it's self and put the Camer aunder it, make it a child of the Empty Object, etc. I've already done that. I've even tried giving the collider the three needed scripts. And take them off the Camera. But it makes the collider go through the other colliders, is why I feel it's the script canceling out the collider.

Now I'd give you the script, but it's the default Unity Construction Worker scripts. So just find that and you have the script.

Any help? And sorry this is wordy. I just tried cancelling out all of the things I've tried to get specific answers.

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by Cherno · Apr 11, 2015 at 11:34 AM

Cast a ray from the camera target back towards the camera. If it hits anything, move the camera to the hit.point. Done.

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 MatiasPi · Apr 20, 2016 at 02:02 PM 0
Share

I couldn't believe it was that simple, but it worked for me. Thank you so much!

avatar image Ignacii · Feb 26, 2018 at 09:35 PM 0
Share

Thanks! This got me going

avatar image
1

Answer by rob5300 · Apr 11, 2015 at 11:17 AM

This is most likelly happening because the movement of the camera is not done via physics. I expect also the camera does not have a rigidbody eathier.

For this to work, you are going to have to eathier edit the script to make the camera move foward when it would go into an object to avoid it or make the camera movements happen via physics (like adding forces).

The Camera will require a rigidbody then, which you won't want using gravity ofcourse and it may need to be set as Is Kinematic, not sure.

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
avatar image
0

Answer by vanjasretenovic123 · Feb 26, 2018 at 09:50 PM

U have to add Sphere Collider to Camera and to another objects if you didn't added. And you have to attach Rigid Body to Camera.

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

Smooth Camera 2 Answers

How can i check if GO collided with collider starting with name (string) 1 Answer

Camera Collison with scene objects 1 Answer

Camera gets flung off of the map when the player collides with certain objects. 0 Answers

Gameobject collision with Terrain C# 4 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