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
0
Question by Sam_Pr · Dec 26, 2012 at 08:59 AM · cameracollisionrigidbodywall

Smart camera?

I need to figure out how to do a camera that avoids the walls like in most games. I've tried everything I could think of including collision, rigidbodys, springs, hinges, and so forth, but I haven't found a method like that yet... I'd really like to know of a method that allows you to throw it together with little to no scripting so it doesn't take so long to add it to lots of things, but I'm willing to do a script if that's what it takes.

Thank you for any help.

  • unity noob

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

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by jeango · Dec 26, 2012 at 09:37 AM

I was thinking about this the other day. I haven't tried this yet, but I was thinking of the following method (works only if your camera is pointed straight to your player):

Have your camera use a raycast, if whatever collides with your ray is something else than your player (meaning there's an obstacle between your cam and player), reduce the distance between your cam and your player so that the new position of the camera is beyond the collision point.

You could add a minimum distance as well, that would switch to first person camera when the third person camera would be too close (if you're back against a wall or something.

It's just an idea I had the other day, don't know if it will turn out OK though. I can imagine some examples where it would be a problem (like if an enemy comes between the cam and player) but you could always solve that by using collision matrix

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 Sam_Pr · Dec 27, 2012 at 02:11 AM 0
Share

Thanks so much this is a great idea!

avatar image jeango · Dec 27, 2012 at 06:54 AM 0
Share

Let us know if it works out fine, like I said, it's just an idea I never actually tried this.

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

10 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

Related Questions

Helicopter Crash Collision 0 Answers

RigidBody stuck on wall when jumped against 7 Answers

Addforce to ball in camera position 0 Answers

Spawn rigidbody on collision 1 Answer

stop camera when collision withh a wall ???? 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