Updated on
May 2, 2024
In this VR Builder tutorial, you will learn about Scene Object Groups. What are they and how to use them? In detail, you will learn the following concepts:
Previously in VR Builder, objects had to be handled and referenced one by one. Thinking of easing the development process for our users, groups were conceived as a new way of managing objects.
This new system will help you reference categories of objects in conditions and behaviors.
We will explain what you can do with groups and their features with the example of a christmas VR app! In this app, you will be able to decorate a christmas tree in VR. Since we want to use a lot of different ornaments, it would be cumbersome to reference all of them one-by-one, so using groups will come in handy! Let's get started.
The scene will be composed of our christmas tree, some spheres, light bulbs and the centerpiece: The star. In VR, the user can grab and place every ornament in the christmas tree, and the workflow should finish as any christmas tree decoration, by setting the star at the top which will activate blinking christmas lights.
For this scene we already imported VR Builder. If you are a new user to VR Builder, please refer to the tutorial about setting up a Unity project with VR Builder.
Let’s start by classifying the Christmas ornaments by shape, select one of the spheres and in the inspector window add a new component. Inside the Process Scene Object component, create a spheres group by writing the name, and clicking on Assign New Group, in this way the group will be created and added to the object.
To assign an existing group to another sphere, select the “spheres” group from the drop down that appears by clicking on the “Assign Group” button.
Do this to the remaining spheres.
To remove a group from an object you simply have to click on the X button positioned to the left of the name of the group to be removed.
To delete completely or modify an existing group from the project, go to VR Builder Settings using Tools>VR Builder>Settings
In the “VR Builder” Collapsible menu to the left, you will find the “Scene Object Groups” section.
Here you can rename groups or delete them by using the garbage can next to the name.
This window also provides an overview of how many objects have an existing group in the current scene. You can click on the triangle on the left to expand a list of objects, and then click the “Show” button to highlight them in the inspector.
Groups can also be used in conditions and behaviors. This new characteristic will allow the user to reference only the group while configuring the step instead of referencing unique, existing objects.
Let’s try this by making the spheres grabbable. Select a sphere and add a grabbable component in the inspector.
Create a step called “Decoration” and go to the “Unlocked Objects” tab. We could use the “Grab object” transition, but to allow freedom of decoration let’s add the spheres to unlocked objects. Now we can unlock all the spheres by selecting the desired group in the dropdown menu that appears when clicking on “Add group to unlock list”.
A new menu with the properties to unlock the objects in said group will appear.
Remember to check the “GrabbableProperty” and “TouchableProperty”.
To end the decoration step, how about we finish off by positioning a star on the top of the tree?
Let’s create a “Snap Object” transition with the star.
By adding this step the spheres will remain grabbable until the star object is positioned.
It’s also possible to add multiple groups to objects, this will allow the user to classify and handle them from a general manner to a particular one.
In this case we could experiment with this by adding an “ornaments” group, we can assign this group to the spheres and to the star at the top.
The basic Enable/Disable Object behaviors also work with groups: let’s try them out.
Select all the light 3D models, and add in the Process Scene object, assign the new group. In this case it will be lights, in this manner we can assign the same group to any number of objects.
But, what does it mean if you already have some group marked in italics when you select several objects? Well, that means that a group is assigned on some but not all objects.
If you would like to fix this, you can remove the group, or assign it to the rest of the items.
We can set the christmas lights in this step, inside the Process Editor create a new step.
In this step, we should create a behavior sequence, this will allow the selected behaviors to repeat themselves after completing
Inside the behavior sequence we create 4 behaviors, which will be triggered consecutively in this order:
And click on the “Repeat” checkbox.
This is how we will simulate the blinking of the lights.
As a final touch, you could have a loop in this demo by connecting both steps.
We still need a transition for the light step to move into the decoration step. Let’s set the “Grab Objects” Transition. And referencing a group that’s present on the star. In my case, I assigned the “star” group to it.
In this VR Builder tutorial you have learned what the groups are and how to make use of them.
You can improve this demo by augmenting the amount of groups and different behaviors to them, attempting to create a spawner for the spheres or adding more different types of ornaments.
If you have any further questions, please join the VR Builder community on discord and get in touch with VR Builder users and developers.