Relevant ViRSE documentation is linked at the bottom of this page

<aside> <img src="https://prod-files-secure.s3.us-west-2.amazonaws.com/4f0e98f6-9e1b-4dfa-9a24-c7a0d1e07d4e/18951595-cafa-4f1a-a7fa-85a148203a4b/V_logo.png" alt="https://prod-files-secure.s3.us-west-2.amazonaws.com/4f0e98f6-9e1b-4dfa-9a24-c7a0d1e07d4e/18951595-cafa-4f1a-a7fa-85a148203a4b/V_logo.png" width="40px" /> Don’t forget that there are completed versions of the code and configuration for every lesson in this course under Assets\YOUR_PLUGIN_HERE\Training in your project. **We encourage you to try to follow these exercises yourself and write the code, but we also don’t want you to spend too long on things if you get stuck.

Feel free to refer to the provided code and ask questions on Discord. We’re very happy to help!

</aside>

Lesson Three

Lesson Three Walkthrough

Lesson Three Walkthrough

Advanced Adjustables

In the previous lesson, you practised linking activatables up to public methods that you wrote in scripts. This is a common pattern in ViRSE (and Unity in general), and in this lesson you’ll do the same with adjustables!

When working with adjustables, you need to declare functions that take a float parameter to capture the value that the adjustable is currently set to.

Defining a function to be invoked by the adjustable, which takes a float as a parameter

Defining a function to be invoked by the adjustable, which takes a float as a parameter

As with activatables, drag and drop the gameobject containing your script into the appropriate event on the adjustable inspector. Then, select your function to tell the adjustable to invoke that function when the event occurs, passing the float value.

Our Adjustable, configured to invoke our public function

Our Adjustable, configured to invoke our public function

You will notice that there are two types of OnValueAdjusted events in the adjustable - one called OnValueAdjusted and another called OnValueAdjustedBasic. ****The first method takes both the adjustable value float and a string which contains the ID of the player interacting with the adjustable, which can be useful in some multiplayer contexts. The basic method uses only the adjustable value float parameter.

In this exercise you’ll link your methods to the adjustable’s OnValueAdjustedBasic event, rather than OnValueAdjusted, because the game you’re building won’t make use of the player ID string.

<aside> 📝 Exercise One - Adjust the speed of the target

<aside> 📝 Exercise Two - Adjust the scale of the target

GrabbableAdjustables

<aside> ⚠️ This section is all extension material. You will need to have completed extension exercise 1B in Lesson Two to do this. if you’d rather skip over this extension material, feel free to jump ahead to UIs

</aside>

Similar to GrabActivatables, GrabAdjustables are components that can be attached to Gameobjects that already contain a FreeGrabbable to allow for hand-held adjustable functionality. In VR mode, adjusting is done with the thumbstick on the VR controller. In non-VR mode, the mouse’s scroll wheel is used instead.