I have less than a years experience developing VR content, I do however learn like a sponge, Information goes in my brain and is stored for ever more. I have found this to be the case on things that take a huge interest form me like VR development. With that being said in the VR dev world the is a lot of information I just seem to understand and it difficult for me to explain why.
I could take the time and explain in my best possible way what each script does and so on, But this is a reflective blog. Reflecting on the work I am doing in the project. Not teaching.
Over the course of my University life, I have found I work best by just doing, Simple as that do something then see the outcome, If it doesn't work, problem solve then fix it. The online world of the internet is my go to place for when I need help but I do first try myself to understand what the problem is.
So lets start this project off:
Creating VR Rig
The VR rig homes all the components for the VR setup to work correctly.
Hand Presence
This script allows unity to select a controller model for the player depending on what VR headset is being used, If headset is not on the list the script will default to a basic controller. I also set up the hand animation for Oculus default hand model that will be used for all headsets using an animator to create a simple grab and pinch animation.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
public class HandPresence : MonoBehaviour
{
public bool showController = false;
public InputDeviceCharacteristics controllerCharacteristics;
public List<GameObject> controllerPrefabs;
public GameObject handModelPrefab;
private InputDevice targetDevice;
private GameObject spawnedController;
private GameObject spawnedHandModel;
private Animator handAnimator;
// Start is called before the first frame update
void Start()
{
TryInitialize();
}
void TryInitialize()
{
List<InputDevice> devices = new List<InputDevice>();
InputDevices.GetDevicesWithCharacteristics(controllerCharacteristics, devices);
foreach (var item in devices)
{
Debug.Log(item.name + item.characteristics);
}
if (devices.Count > 0)
{
targetDevice = devices[0];
GameObject prefab = controllerPrefabs.Find(controller => controller.name == targetDevice.name);
if (prefab)
{
spawnedController = Instantiate(prefab, transform);
}
else
{
Debug.LogError("Error");
spawnedController = Instantiate(controllerPrefabs[0], transform);
}
spawnedHandModel = Instantiate(handModelPrefab, transform);
handAnimator = spawnedHandModel.GetComponent<Animator>();
}
}
void UpdateHandAnimation()
{
if (targetDevice.TryGetFeatureValue(CommonUsages.trigger, out float triggerValue))
{
handAnimator.SetFloat("Trigger", triggerValue);
}
else
{
handAnimator.SetFloat("Trigger", 0);
}
if (targetDevice.TryGetFeatureValue(CommonUsages.grip, out float gripValue))
{
handAnimator.SetFloat("Grip", gripValue);
}
else
{
handAnimator.SetFloat("Grip", 0);
}
}
// Update is called once per frame
void Update()
{
if (!targetDevice.isValid)
{
TryInitialize();
}
else
{
if (showController)
{
spawnedHandModel.SetActive(false);
spawnedController.SetActive(true);
}
else
{
spawnedHandModel.SetActive(true);
spawnedController.SetActive(false);
UpdateHandAnimation();
}
}
}
}

This was also applied to the players left hand.
So far everything is working perfectly. With zero errors. Fingers cross it stays that way further down the line.
Team Feedback
Meeting with Juan to discuss the project and a potential meet with Barclays team working on the eagle labs. But main question being how much creative freedom we have on this project.
Comments
Post a Comment