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 Panopolos · Jan 08, 2013 at 03:37 AM · cameraphysicsrigidbodycolliderpathfinding

Camera Stuck on Wall Corners

Hello all,

So here's the deal. I have a camera parented to a gameobject that rotates based on the mouse or right control stick on the controller. When it rotates, the offset camera "orbits" around to create an kind of fake mouse orbit for the camera.

I also put a sphere collider and a rigidbody on it so it wouldn't go through walls. This was pushing the camera to odd angles, so I wrote a script that detects collisions with the environment, or at least objects tagged as "environment". It will be pushed around for as long as the collision in happening, but after the collision exits it will slerp back to its start position offset from its parent. This works pretty well.

However, I'm finding that as the player walks around sharp corners, the camera gets stuck on the corners. It drags along the edge until

A) the player manually rotates the camera around the corner when it will promptly tween back to the correct position or B) it drags to the edge of the corner after some time, is able to exit collision, then tweens back to the correct position. This can take a while as it drags along the wall very slowly. I tried decreasing the drag and angular drag settings on the camera's rigidbody property (they are usually set to infinity), but it just allows the camera to bounce around in an unwanted manner if it collides too hard, it has no bearing on the friction.

Speaking of, I have attached a physics material to the collider on the camera with zeroed friction settings up and down, but that doesn't seem to make a difference having it on the collider or not.

My current solution is to check the distance between the camera and its parent and if it's past a certain distance, to automatically tween it back to its starting position. However, this causes the camera to fly through walls ignoring collisions altogether. This isn't ideal, as I don't want the camera to see through walls.

So I think the correct thing to do would be to implement some sort of pathfinding intelligence for the camera if the distance check fails. However, I'm not the guy on our team working on AI, in fact I don't even know him and he's working remotely, so I can't ask his advice. That is to say, I have no experience with pathfinding. I could learn some pathfinding basics to get this figured out, but I'd rather not take the time out of my work cycle right now if this isn't the way to go.

So my question is: Will I find the answer to my issue in pathfinding, or is there a better way to deal with his issue?

Thanks!

-Long-winded Panopolos

Comment
Add comment · Show 1
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 Josh707 · Jan 08, 2013 at 03:57 AM 0
Share

I'm thinking of something like pushing the camera with actual forces in the opposite direction of the collision, it might make it flow over bumps.

0 Replies

· Add your reply
  • Sort: 

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

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

Rigidbodies won't collide if mass difference is too high 0 Answers

Guidelines for using rigidbody, collider, CharacterControllerScript, etc? 3 Answers

How to get collisions on Character controller? 1 Answer

OnCollisionEnter isnt called when player lands on object 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