Make a prototype of interactive lighting. Getting familiar with Blueprint coding.
Final Result Explanation:
I made blueprints to model three different types of lights: point light, directional light and spot light. All the lights are intractable. You can pick up the light and move / rotate it and you can change its parameters. The lights can be turned on and off with a button, also made with blueprint.
Things I’ve learnt & Problems I’ve met
1. Fake mesh light
If you make the material unlit and make the mesh no cast shadow, the light inside will pass through the object.
Also, I found that if the material is unlit, the ‘cast shadow’ option is turned off. In the picture below, it shows the spot light I made cast shadows on the desk. This is because there’s a directional light in the scene.
To turn the shadow completely off, you need to deselect dynamic & static shadow options in the Details panel.
2. Using Interface in Blueprint
A Blueprint Interface is a collection of one or more functions – name only, no implementation – that can be added to other Blueprints. Any Blueprint that has the Interface added is guaranteed to have those functions. It means in your blueprint you can call this interface of an object as long as it has implemented this interface. The realization of this interface can vary.
For example, in my case, I made an interface called interact and all the lights and buttons implement this interface. When my controllers touch an object, it calls the interact interface on that object and triggers the right way to handle it.
3. Get input for Vive Controllers
This is the blueprint I made at first. It is part of my HMD pawn class. I enabled input during Event BeginPlay.
It does not work because in Pawn, you need to use possess instead. Also in simulation mode, you can not get input until you pressed possess in the menu bar.
4. Map the experience to reality
When I first run my prototype in VR, the room axis look wrong. It is not aligned with Unreal’s x, y, z. The way to fix it is to do Vive room setup again.
I remeasure my playable area and marked it in my scene. It is 2.9m * 1.6m.
If set track origin to eye level: Since my HMD blueprint was used in a sitting experience, you need to reset the value. I put the controller on the ground and it is not on the virtual ground. Unreal has recommended character height to be 160 cm in this documentation: https://docs.unrealengine.com/latest/INT/Platforms/VR/ContentSetup/#vrcharactersettings. So if you set the Vive Camera Height to 80 (Note it is half the value you want) it will look OK.
If set track origin to floor level: Everything seems work well. The headset orientation is different though. Need more observation.
5. Very Stupid problem: cannot get controller input
Debugged a whole day about this issue… Turns out if you don’t turn on the controller before the app starts, it can not get the input.(Weirdly that the controllers were being tracked.)
Always turn on Vive first before open Unreal.
6. One last thing to note: Unreal’s own VR template. It implements teleportation, pick up and physics, and seems like a good template to use. I am not using it right now for learning purpose and may do in the future.
Here’s a guide to it: http://www.tomlooman.com/vrtemplate/