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 MattBradley · Nov 11, 2013 at 04:54 PM · rotationcollisionphysicsrigidbody

Camera and mesh not colliding

Hello,

I'm trying to get a camera to collide with a mesh, however at the moment I'm having difficulties getting the desired behaviour.

I am making an endless runner type game set in a tunnel. Each piece of the tunnel is comprised of sections featuring obstacles that the play must avoid to progress. To avoid these obstacles the player (camera) must rotate around tunnel.

The problem I have is that when the camera hits an obstacle in the tunnel it passes straight through it. That is unless I turn off all constraints on the rigidbody. If I do that the camera will collide with the obstacle but then a force is applied to both objects. What I would like is for the camera to collide with the obstacle, but no forces to be applied to either, the camera simply should not pass through the obstacle. This also applies to situations where the camera might need to jump onto a mesh within the level as well.

As mentioned above, if I freeze the position and rotation constraints both the camera and obstacle remain fixed on collision (no forces are applied), but the camera passes through. Both the obstacle and the camera have rigidbodies, and box and sphere colliders components respectively.

As far as I can tell this should be fairly simple, however my understanding of Unity's physics system is minimal so it's a lot more complicated than it should be!

Any assistance is greatly appreciated. Thanks.

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
0

Answer by MattBradley · Nov 13, 2013 at 01:12 AM

I've done some further investigation and found that my solution is likely to involve using a joint. At the moment I have a gameobject that controls the camera rotation at 0,0,0. The camera is a child of that object at 0,-20,0. I have a state machine that gets player input to rotate the camera around 0,0,0 with a -20 offset in the y axis.

I now have a fixed joint on the camera with the gameobject at 0,0,0 being the connected body. When I do this the obstacle no longer moves and the camera is generally in the right position unless I continue to try to rotate through the obstacle. If I do this the camera will act very strangely and not remain at 0,-20,0. Instead it rotates itself until it pings off the obstacle and loses its position.

Is there a way to fix this behaviour? I have considered turning off the ability to rotate once a collision has occurred and also to make the the camera rotate only by using forces, but both are a little scary!

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

16 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

Related Questions

How may I observe expected physical interactions while using Rigidbody.MoveRotation()? 1 Answer

Rigidbody doesn't rotate after collision 3 Answers

transform.Rotate and Rigidbody.MovePosition 1 Answer

How to limit the motion direction of a GameObject? 1 Answer

Camera gets flung off of the map when the player collides with certain objects. 0 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