Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

VR Inventory, Pause and Prefabs

Andrew Frateschi

I added a utility belt style inventory onto the VR player, the basic idea is a set of little nodes that follow the VR player's "body" for them to insert and take items from. The initial setup was pretty easy, using the XR interaction socket component did most of the work for me, I just arranged them in a semi-circle around the camera and added a simple script to move them based on a ratio of the camera's height so hopefully it'll generally work for everyone even if they're crotched down or of any height, I plan to include a setting so the player can adjust the ratio to their preference though. One issue I did have with this however was that the sockets would pick up any object that overlapped them regardless of if the player was holding them or not. I played around with the XR API a bit trying to find a decent solution to check if an object is being "selected" or not however I kept running into issues and trouble with this method so I changed tactics and instead decided to make use of the interaction layer mask. Basically within the XR toolkit there is a separate layer system specifically for interaction, so I wrote a simple script to change an objects interaction layer mask when it's selected so that it can be placed inside of an inventory slot and when it's released it waits a few milliseconds then checks to make sure it's not still being selected before it changes the interaction mask back to what it was before, the delay is needed because if the mask changes while it's inside of an inventory node the object will just fall to the ground and the inventory itself counts as being selected.

I also included a simple pause menu to replace the hand-held menu from before, this functions like a traditional pause menu by pausing the game itself and appears in front of the player in world-space. For now the sound sliders are purely placeholders and don't do anything and I haven't implemented the saving and loading features my teammates made, the cheat menu has also been placed inside of this and should be fully functional in all scenes now. Other then that most of my time this week has been spent making changes to and creating prefabs for interactable objects in VR, mostly to implement the new scripts needed to put objects in the inventory, but also to make it easier for me to update scenes with VR versions. 

Support this post

Did you like this post? Tell us

Leave a comment

Log in with your itch.io account to leave a comment.