Uploaded July 2019 | Updated November 2026, 1 hour ago
There are two ways to handle input in your VR games built with Unity. Right now we have used Unity's `Input` system to allow us to create Axis and Buttons which can be retrieved using the normal `Input.GetAxis` methods. This is... clunky... in VR. Different Headsets have different capabilities and various controllers will support different types of input. Continuing to rely on the `Input` class will mean that we'll have to implement some sort of system to check the capabilities of the device that we're using and see what features we can use to power our locomotion and other inputs. Luckily Unity has already implemented this system and created the XR Input system.
The XR Input system exists in parallel to the normal `Input` system that I've used in the past. Unlike `Input` which makes it possible to track inputs from specific pre-defined things, we can use the XR Input system to query the current capabilities of the VR system our computer is running. This makes it possible for us to ask Unity for the "Right Hand" or another similar object and get something understandable back. Once we have that object we can test various capabilities of the "Right Hand" such as the Trigger or Primary Axis of the controller. This makes it possible for us to have a lot more control over how input in our game works and also makes it far easier for us to adopt our game to different controllers used in VR.
This is my first time working with this new system and while it has its quirks (most VR API's are still maturing in my experience) I'm pretty happy with how well it works. Adopting it is also relatively straight-forward and doesn't require a dramatic amount of additional work when migrating from an existing system built on-top of the original `Input` based system.
What do you think?
Unity's documentation for the XR Input System is here and includes multiple additional examples: docs.unity3d.com/Manual/xr_input.html
The d-pad in this videos thumbnail was created by Lorc for the `game-icons` projects: github.com/game-icons/icons/tree/master/lorc.
Join the World of Zero Discord community: discord.gg/hU5Kq2u
There are two ways to handle input in your VR games built with Unity. Right now we have used Unity's `Input` system to allow us to create Axis and Buttons which can be retrieved using the normal `Input.GetAxis` methods. This is... clunky... in VR. Different Headsets have different capabilities and various controllers will support different types of input. Continuing to rely on the `Input` class will mean that we'll have to implement some sort of system to check the capabilities of the device that we're using and see what features we can use to power our locomotion and other inputs. Luckily Unity has already implemented this system and created the XR Input system.
The XR Input system exists in parallel to the normal `Input` system that I've used in the past. Unlike `Input` which makes it possible to track inputs from specific pre-defined things, we can use the XR Input system to query the current capabilities of the VR system our computer is running. This makes it possible for us to ask Unity for the "Right Hand" or another similar object and get something understandable back. Once we have that object we can test various capabilities of the "Right Hand" such as the Trigger or Primary Axis of the controller. This makes it possible for us to have a lot more control over how input in our game works and also makes it far easier for us to adopt our game to different controllers used in VR.
This is my first time working with this new system and while it has its quirks (most VR API's are still maturing in my experience) I'm pretty happy with how well it works. Adopting it is also relatively straight-forward and doesn't require a dramatic amount of additional work when migrating from an existing system built on-top of the original `Input` based system.
What do you think?
Unity's documentation for the XR Input System is here and includes multiple additional examples: docs.unity3d.com/Manual/xr_input.html
The d-pad in this videos thumbnail was created by Lorc for the `game-icons` projects: github.com/game-icons/icons/tree/master/lorc.
Join the World of Zero Discord community: discord.gg/hU5Kq2u
![Using PowerShell to Create a Symbolic Link on Windows
Symbolic Links allow you to create a reference in your file system to another file or directory. This allows you to reference the same file in multiple places without having to physically copy it into each place. This can save storage space and also allows a single change to the file to be seen by every location that links to it as well.
In this video well be taking a look at how to create these Symbolic Links from PowerShell using a version of the `New-Item` commandlet. In order to take advantage of this youll need to be running in an Administrator PowerShell or you may see the New-Item : Administrator privilege required for this operation error. This solution is able to create symbolic links between files or directories and also will detect if the target item you are creating the link to exists or not before generating the link.
In order to create the symlink in PowerShell youll run this command:
```ps1
New-Item -ItemType SymbolicLink -Path [path] -Target [target]
```
This will create a new Item at the provided path that represents a link to the target file or directory.
If you prefer Command Prompt you can learn how to make a symbolic link in Command Prompt here: https://youtu.be/w2gxWTOPw7U
Join the World of Zero Discord Server: https://discord.gg/hU5Kq2u Using PowerShell to Create a Symbolic Link on Windows](https://i.ytimg.com/vi/_VnONfOgP8M/mqdefault.jpg)


.
When used in a function or property which returns an `IEnumerable`, yield will provide two features. You may `return` the next value in the set or `break` out of the loop - effectively terminating the set. Values `return`ed from a `yield` keyword are composed into the enumerable set as your code evaluates. Yield statements are evaluated lazily (meaning the function generating the enumerable object is not generated completely before the first element is returned), this means that after returning with `yield` the code in the function will continue from the point it returned from including preserving the state (such as local variable values).
Using these concepts we can create a function which returns all positive integers between 1 and a max value.
```csharp
// Note: youll need to replace the IEnumerable˂int˃ with correct syntax as well as the ˃= symbol
public static IEnumerable˂int˃ PositiveInts(int max) {
int i = 1;
while(true) {
yield return i++;
if (i ˃= max) {
yield break;
}
}
}
```
* `yield return`: returns the next value in an `IEnumerable`.
* `yield break`: marks the end of the `IEnumerable`.
More information about using `yield` with some other examples is available here: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/yield
Join the World of Zero Discord Server: https://discord.gg/hU5Kq2u Using C#s Yield Keyword](https://i.ytimg.com/vi/bsZjfuTrPSA/mqdefault.jpg)


 that launches the Inkscape CLI to automatically render images from SVG files in our directory.
The code for this task looks like this:
```csharp
// Search the projects Assets directory and all children directories
var searchDirectory = Path.Combine(Environment.CurrentDirectory, Assets);
Debug.Log($Searching for SVGs in {searchDirectory});
var svgFiles = Directory.EnumerateFiles(searchDirectory, *.svg, SearchOption.AllDirectories);
foreach (var svgFile in svgFiles)
{
// Generate a new path with a PNG extension instead of the original SVG extension - reusing other parts of the path
var pngFile = Path.ChangeExtension(svgFile, png);
Debug.Log($Converting {svgFile} to {pngFile});
Process process = Process.Start(inkscape,
$-o {pngFile} -w 32 -h 32 {svgFile}); //32 is the size in pixels of the width and height of the generated image
process.WaitForExit();
}
Debug.Log(jobs done);
```
You can get a copy of Inkscape here: https://inkscape.org/
The Inkscape Wiki has more information about how you can get started using the Inkscape CLI: https://wiki.inkscape.org/wiki/index.php/Using_the_Command_Line
The icons Im using are from the Material Design Icons set, you can browse the complete set of icons here: https://materialdesignicons.com/
Join the World of Zero Discord Server: https://discord.gg/hU5Kq2u Generating Images from SVGs with Unity and Inkscape](https://i.ytimg.com/vi/dnDz4lVbMWw/mqdefault.jpg)

 from an earlier video on the channel.
When this grid snapping is applied against a mesh there are a few additional decisions we need to make. This includes what coordinate space we want to perform the operation in. Coordinate spaces describe an object relative to that space. For example an object space representation is an identical representation for each version of that object whereas a world space version of the same object would describe the unique position, rotation and scale of that object in the world. Which coordinate space we decide to create our grid in will effect the final result: if we snap vertices in object space then even as that object is rotated or moved through the world the rounded vertices will not change. However if we perform the grid snapping in world space the final results will change as the object is moved and rotated through the world. Depending on the effect we want to achieve different coordinate spaces may be more appropriate. For our testing purposes though well just use object space since this is the most straightforward to implement.
The vertex shader code that snaps to a grid looks like this (this is the surface shader implementation):
```shader
void vert(inout appdata_full v) {
v.vertex /= _GridSize;
v.vertex = round(v.vertex);
v.vertex *= _GridSize;
}
```
Note: the syntax is slightly different between the Surface Shader and Vertex Shader implementations however the principals are the same. Both implementations are demonstrated in the video.
You can view the entire playlist of implementing this effect here: https://www.youtube.com/playlist?list=PLEwYhelKHmiixWR3Tn5dYt1iUlSCL6OFq
***
More Visual Effects weve built on World of Zero: https://www.youtube.com/playlist?list=PLEwYhelKHmig6ttzH0nRL3OOQsGLtVrtX
Unitys Surface Shader examples: https://docs.unity3d.com/Manual/SL-SurfaceShaderExamples.html
If youre interested in learning more about coordinate spaces (object space/world space/etc) this article goes into a bit more depth and also describes the relationships between the different coordinate spaces: http://davidlively.com/programming/graphics/coordinate-spaces/
The Bomber Bug asset is located here: https://assetstore.unity.com/packages/p/bomber-bug-pack-pbr-63127
Come chat in the World of Zero Discord Server: https://discord.gg/hU5Kq2u What Happens When You Snap Vertices To A Grid?](https://i.ytimg.com/vi/e8NItqF_9hQ/mqdefault.jpg)

