Assignment 5 – First Unity Scene: HTC Vive and Basic Combat

Assignment 5 – First Unity Scene: HTC Vive and Basic Combat


For my first Unity scene I created a small medieval scene with the outside of a house and a small castle corridor. I ported it into the HTC Vive and scripted a simple melee system that works with the hand controllers.

 

 

Things that worked:

For the most part, creating the actual scene in Unity was simple enough. I adjusted terrain and created a crater in which my scene took place so the player doesn't venture too far outside the scene. I found some free assets from the store for the house and props including a sword and weapon pack, which I mapped to the controllers. For the lamps I had to get a lamp prop and then create a 'light' object that was centered on the lamp, and adjusted the hue and brightness to mimic what kind of light I thought the lamp would give off. When creating scenes in Unity it helps to study lighting because it can really enhance a scene and, in turn, the resulting feeling of 'presence' in virtual reality.

 

Things that didn't work:

SteamVR. The actual process of porting the project to the Vive was simple enough, you just download the free pack from the asset store and add the "Camera Rig" Prefab to your scene instead of the First Person Controller. (You can keep the first person controller in the scene and just disable it if you want to be able to jump back and forth between Vive and regular monitor play while editing.) There was slight jitter when looking through the headset and fixing that is one of my future goals, as it really breaks immersion, but it's not game-breaking.

The difficult part was getting the controllers to work properly. Just seeing the controllers in the headset was easy enough, and that came with the prefab, but anything beyond that required some scripting (minimal, for the basics) to get to work correctly. For the teleport feature, one of the scripts given in the SteamVR asset pack had a line that was missing, which I talked about in THIS blog post. That was only adding one line of code, so it was a pretty easy fix once I found the answer.

The most difficult maneuver was getting the combat system to work. I found a tutorial on youtube for a basic melee combat system. It wasn't tailored to VR at all and was uploaded in 2012, but it was a start. I altered it to fit the Vive controllers by getting the position of Object 1 (the controller / sword hitbox) and compare it to the position of Object 2 (the enemy hitbox) and if the distance between the positions is less than a number I set (currently it's set to about .5 meters) then take away health. (For purposes of the video I made it add health, to count how many hits you have done.) This is what took the longest, but I think this basic system could be the building block for both a full-fledged combat system or any system where you have to compare distances between the controller and an object. Once I clean up the code and add annotations I can share it in another blog post.

 

Where to go from here, longer project ideas:

Having the knowledge to set up a project for the HTC Vive and get teleportation working is a really great start to working with the interface. What I have done so far can be the basis for a very simple combat arena game.

However, to truly utilize the medium of virtual reality, you have to tell a story that engages the user and grounds them in the world you created.

To be fair, coming up with stories is one of my weak points, but with these basic tools I created can take a story that has been told and put it into Unity, to tell it differently, make it more interactive.

For example, one of my favorite scenes from a fiction book, 'The Way of Shadows' by Brent Weeks has a scene in which a teenage lord is sparring with his men, winning every time. A new man approaches and, thinking he is the greatest sword fighter in the area, the lord challenges this man. The man quickly defeats him, giving the lord the lesson of humility. This scene is perfect for the Vive, as it takes place in a relatively small space and can tell the story interactively, either through the eyes of one of the lord's guards, or the newcomer.

 

I'm excited for this week's class, and learning animation. I was watching another student work on recording animations with a Kinect sensor, and hope to be able to include such animations for my final project, giving it more realism.

 

Follow me on twitter @ProjectSevan for more #VRStorytelling tweets and subscribe to my Youtube page, where I will be posting updates to Unity and more 360° Video Projects.