Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 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
0
Question by kuos · Dec 23, 2015 at 03:06 AM · collisionrigidbodycollidercamera-movement

Prevent player from walking through/pushing walls that are Rigidbodies and have Box colliders

I have a player ( camera object ) in Virtual Reality Environment. The player is in a room with objects like a table and walls. The tables and walls both have a rigidbody and a box collider on them. I messed with the player adding a rigidbody and capsule collider, but I end up either walking through walls, pushing walls, or flopping over as a result of running into the table. I set the walls and table's Rigidbody mass to max 1e7?

How do I make it so that the player simply cannot walk through the table nor walk through the walls without pushing each other?

Comment
Add comment · Show 8
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 ZefanS · Dec 23, 2015 at 07:46 AM 2
Share

If you don't need gravity on the walls or table, etc. under the Rigidbody settings you can check Is $$anonymous$$inemetic and uncheck Use Gravity. This will essentially make them static unmovable objects in the scene.

avatar image Sageose ZefanS · Dec 23, 2015 at 08:29 AM 0
Share

Also, make sure you are moving the rigidbody, not the transform.

avatar image kuos Sageose · Dec 23, 2015 at 08:30 PM 0
Share

$$anonymous$$y script moves the camera transform(Virtual reality Google cardboard camera head) so is there a way to work around it? Does transform always walk through other objects?

Show more comments
avatar image kuos ZefanS · Dec 23, 2015 at 08:23 PM 0
Share

So if my player is the camera object do i need a 3D Capsule as the camera's parent or can i just put a box collider(make the collider like a vertical rectangle) and attach a rigidbody? The walls i can put rigidbody, is $$anonymous$$inematic, no Gravity.

avatar image Sageose kuos · Dec 23, 2015 at 08:26 PM 0
Share

A camera object with a box collider and a rigidbody is pretty much the same as a cube with a box collider and a rigidbody and a child camera object, except it has a mesh renderer. Personally I'd probably make a 3d capsule gameobject and make the camera object it's child.

Show more comments
avatar image Sageose · Dec 25, 2015 at 12:53 PM 0
Share

You could perhaps move the rigidbody by changing the script to this: if (isWalking) { lVel = transform.InverseTransformDirection(GetComponent().velocity); lVel[2] = speed; //or any direction that is forward in local position from the player GetComponent().velocity = transform.TransformDirection(lVel); }

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ybaklaci · Oct 12, 2017 at 10:48 AM

You don't need a rigidbody to stop your character from walking through walls. The OVR utility from Oculus has a Player Controller (with a CharacterController component) which handles this. If you want to achieve it by yourself, you can use a Capsule collider (CharacterController already has it) and stop the transfrom on a collision.

But, if your aim is also to stop the Camera from looking through objetcs, that's a bit tricky. Keep in mind that CharacterController is moved by using buttons on the remote, or by some kind of game controller. So, it is easy just to stop reacting to the input by the user. What you can't stop, is the positional tracking of the headset, which is strictly synced with the Camera.

As a fast solution to all of these, there is an asset called Head Collision VR. I also refer to the problem of head collision in depth in this answer.

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

43 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 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

handling collision with two objects of the same tag 1 Answer

Collisions between two rigidbody's and scripting collisions problem 2 Answers

How to allow collisions on a Child of a Non Kinematic RigidBody ? 1 Answer

Collider question 0 Answers

Rigidbody stuck in colliders when moving and ricosheting. 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