• 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 Eco-Editor · Jun 26, 2017 at 09:06 PM · vrsceneviewlocalpositionmathf.clamp

How to mathf.clamp a VR player?

Hello,

In walking simulation I want to restrict the players movement in VR, to the navmesh so I can control the players position from walls. I've used mathf.clam of a localPosition for the cameraEye component in [cameraRig], and clamped the min and max, x and z positions. While in playmode in the scene view this works perfectly, but in reality when placing the HTC Vive the user has free movement again. Have you encountered such issue before? How would you go about this?

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
Best Answer

Answer by Jwizard93 · Jun 26, 2017 at 10:31 PM

It's been a hot minute since I experienced this issue. If my memory serves me I overcame it by making my VR player a child of another transform. I could limit that transforms position. Be careful, though. Messing with rotation of this parent transform should be totally under the user's control (if it can rotate at all.)

It can be sickening to have rotation controls taken away from the player.

Edit: This should be used stop any touchpad/joystick/WASD input from allowing them to walk too close to walls. You DO NOT want a situation where the player walks in the real world and doesn't see the correctly updated image. Other games handle this by first doing what i mentioned above, then fading the image away as they get further from the intended play area. This is a much nicer nudge in the right direction for the player.

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 Eco-Editor · Jun 28, 2017 at 03:59 PM 0
Share

Hi, I'm using s$$anonymous$$mVR's cameraRig prefab and the user is walking freely in the room, without using joystick or touchpad. I've $$anonymous$$athf.Clamped the cameraEye position to the location of the parent, aka the cameraRig, as the real parent "cameraHead" is disabled during play in VR.

Any idea how to limit the users movement in this case?

avatar image Jwizard93 Eco-Editor · Jun 28, 2017 at 08:35 PM 0
Share

If I'm understanding you correctly then the only method of movement in your game is through actually walking in the real world. In that case, and with all due respect, you are trying to make a HUGE $$anonymous$$ISTA$$anonymous$$E!

Imagine yourself playing this game. You walk over to the edge of your nav mesh. Then you take one more step. But wait! You moved forward in the real world but the image you see is still what it was before your last step. You fall down, you throw up, you get scared, and you never want to play VR again. The bones inside your ear are telling your brain that your eyes are not to be trusted and the natural reaction is less than pleasant.

The VR industry has decided as a whole that this behavior is undesirable and the makers of the prefab have gone through steps to ensure that you, as a dev, cannot put someone through something miserable.

This is why you CANNOT clamp the transforms on that prefab. What you CAN do is make an empty GameObject and make the prefab a child of that object. Now you can limit the position of that object. Consider that object the center of the player's tracked space. Joystick input or warping mechanics can move that transform around. And that position can be limited. But the players location relative to that transform are entirely dictated by the information received from the VR hardware. Really.. don't mess with that.

If the player leaves the path. Let them know gently. $$anonymous$$ake it easy to return to the right path. And make sure something is drawn to give the player a 3D reference to where they are no matter what is going on.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

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

Related Questions

Clamping local movement 0 Answers

Moving VR Button in LocalSpace with only one axis Unlocked 0 Answers

What are Camera Types for? 1 Answer

Scene view different with camera view/VR view 0 Answers

Locals How to get rid of them can I disable them??? 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