Daggerfall Unity VR with the Vive Pro
- InconsolableCellist
- Posts: 100
- Joined: Mon Mar 23, 2015 6:00 am
Re: Daggerfall Unity VR with the Vive Pro
With many thanks to a model by quasifex, here's a quick demo showing how your hands will appear in VR! https://www.youtube.com/watch?v=p2jt3qb5WIE
Pointing will be used for interacting with things, or as a hint that something can be interacted with. It'll also have to grip your weapons, which will mean I'll have to make a bunch more animations.
Pointing will be used for interacting with things, or as a hint that something can be interacted with. It'll also have to grip your weapons, which will mean I'll have to make a bunch more animations.
- Interkarma
- Posts: 7249
- Joined: Sun Mar 22, 2015 1:51 am
Re: Daggerfall Unity VR with the Vive Pro
This is shaping up, I like it!
-
- Posts: 11
- Joined: Wed Jul 29, 2015 9:11 am
Re: Daggerfall Unity VR with the Vive Pro
Will this work with Windows MR headsets?
- InconsolableCellist
- Posts: 100
- Joined: Mon Mar 23, 2015 6:00 am
Re: Daggerfall Unity VR with the Vive Pro
Unity might have support for that, I'm not sure, but I don't really have a way of ensuring my code is device-agnostic. So I'm going to say no, it probably won't work properly, unless you know for a fact that the MR works really well with Steam's VR toolkit, and even then some of the alignment of weapons and the controller might be off.
As an update, I haven't forgotten about this project! However I'm moving across the country in the next few weeks and I won't even have my Vive with me for a few weeks after that, so I'm going to have to pause.
As an update, I haven't forgotten about this project! However I'm moving across the country in the next few weeks and I won't even have my Vive with me for a few weeks after that, so I'm going to have to pause.
- InconsolableCellist
- Posts: 100
- Joined: Mon Mar 23, 2015 6:00 am
Re: Daggerfall Unity VR with the Vive Pro
As an update, I'm not dead. My stuff's in storage as I wait to close on a house!
- Hazelnut
- Posts: 3016
- Joined: Sat Aug 26, 2017 2:46 pm
- Contact:
Re: Daggerfall Unity VR with the Vive Pro
Good luck! It's a nerve-wracking time waiting for closing.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods
-
- Posts: 1
- Joined: Thu Jun 27, 2019 6:37 pm
Re: Daggerfall Unity VR with the Vive Pro
Just curious if this mod is still being worked on. Hope closing the house went well.
- InconsolableCellist
- Posts: 100
- Joined: Mon Mar 23, 2015 6:00 am
Re: Daggerfall Unity VR with the Vive Pro
Thanks! The last few months have been nuts. I moved into a temporary place, went house hunting, bought a place, moved in, went back home, moved all my stuff, visited family, family visited me, etc., etc. It's been insane.dodossssssssss wrote: ↑Thu Jun 27, 2019 6:45 pm Just curious if this mod is still being worked on. Hope closing the house went well.
The good news is I'm pretty much all set up. I have my Vive installed in my basement with my gaming computer, but the only missing piece is to relocate the computer to an actual desk down there, so I can program in comfort. Sitting in front of the TV doesn't cut it.
So basically, the mod is still paused. I've also been playing through Daggerfall Unity just for fun, and I'm blown away by how good all the mods are. Everyone's doing such incredible work, it never ceases to amaze me.
I'd like to continue the mod for sure. The foundation of injecting the VR components shouldn't change, but I am a bit worried now that it's not cross-platform enough. I had gotten my father an Odyssey+, which had different controllers, and I think I should design the mod to be capable of switching between different types.
-
- Posts: 16
- Joined: Thu Aug 29, 2019 11:33 pm
Re: Daggerfall Unity VR with the Vive Pro
Necro bump
Just a head's up: I've begun updating your solution (using the latest SteamVR, and version of the game) and expanding on it. Here's my fork: https://github.com/Vwing/daggerfall-unity-1. I'm mostly working in the VR_update branch (Edit 9/2/19: That branch is no longer, I've merged into the VR branch).
Since I'm using the new SteamVR Input system, this should work for any headset; just need to set up the input bindings, and even the end user can do that. I have only set up the Oculus Rift bindings, so far, but I also have a Vive to work with. I know a colleague with a Windows Mixed Reality, so I can set that up some time as well.
I made it so player movement is the same as in the game, with all the checks and whatnot untampered with. Movement is now based on your current look position rather than the forward of the controller. I've done a few other tweaks and fixes here and there, details are in my commits.
Interaction with UI is currently broken, and interaction with world objects only works inconsistently. Fixing that is now my highest priority, then maybe I'll move on to combat
EDIT: I think I see why we can no longer click UI elements with the VR controllers. BaseScreenComponent.cs is looking for the "VRTrigger" button, but I don't think that works in a properly cross-headset way. Not sure how to go about injecting it, either... would probably need to implement a DaggerfallInput class that goes in the base game, and the VR mod can call something like DaggerfallInput.SetMouseButtonDown(0) when the "InteractUI" SteamVR input action is activated.
Just a head's up: I've begun updating your solution (using the latest SteamVR, and version of the game) and expanding on it. Here's my fork: https://github.com/Vwing/daggerfall-unity-1. I'm mostly working in the VR_update branch (Edit 9/2/19: That branch is no longer, I've merged into the VR branch).
Since I'm using the new SteamVR Input system, this should work for any headset; just need to set up the input bindings, and even the end user can do that. I have only set up the Oculus Rift bindings, so far, but I also have a Vive to work with. I know a colleague with a Windows Mixed Reality, so I can set that up some time as well.
I made it so player movement is the same as in the game, with all the checks and whatnot untampered with. Movement is now based on your current look position rather than the forward of the controller. I've done a few other tweaks and fixes here and there, details are in my commits.
Interaction with UI is currently broken, and interaction with world objects only works inconsistently. Fixing that is now my highest priority, then maybe I'll move on to combat
EDIT: I think I see why we can no longer click UI elements with the VR controllers. BaseScreenComponent.cs is looking for the "VRTrigger" button, but I don't think that works in a properly cross-headset way. Not sure how to go about injecting it, either... would probably need to implement a DaggerfallInput class that goes in the base game, and the VR mod can call something like DaggerfallInput.SetMouseButtonDown(0) when the "InteractUI" SteamVR input action is activated.
// Get left and right mouse down for general click handling and double-click sampling
bool leftMouseDown = Input.GetMouseButtonDown(0) || Input.GetButtonDown("VRTrigger");
bool rightMouseDown = Input.GetMouseButtonDown(1);
bool middleMouseDown = Input.GetMouseButtonDown(2);
// Get left and right mouse down for up/down events
bool leftMouseHeldDown = Input.GetMouseButton(0) || Input.GetButton("VRTrigger");
bool rightMouseHeldDown = Input.GetMouseButton(1);
bool middleMouseHeldDown = Input.GetMouseButton(2);
Last edited by Vwing on Mon Sep 02, 2019 8:31 pm, edited 1 time in total.
-
- Posts: 16
- Joined: Thu Aug 29, 2019 11:33 pm
Re: Daggerfall Unity VR with the Vive Pro
Okay, here's what I made:
Which can be implemented elsewhere with something like this:
And I changed the code in BaseScreenComponent to use DaggerfallInput instead of Input:
Code: Select all
namespace DaggerfallWorkshop.Game.UserInterface
{
/// <summary>
/// Has some of the same functionality as UnityEngine's Input class, but allows for setting custom states.
/// </summary>
public class DaggerfallInput
{
private const int NUM_MOUSE_BUTTONS = 7; //there are 7 mouse inputs in the Unity KeyCodes. MouseDown0 to MouseDown6
private static bool[] customMouseIsDown = new bool[NUM_MOUSE_BUTTONS];
private static bool[] customMouseWasDown = new bool[NUM_MOUSE_BUTTONS];
private static int[] lastFrameCustomMouseStateWasSet = new int[NUM_MOUSE_BUTTONS];
//get custom and actual mouse button states
public static bool GetMouseButtonUp(int button)
{
return Input.GetMouseButtonUp(button) || (button < NUM_MOUSE_BUTTONS && !customMouseIsDown[button] && customMouseWasDown[button]);
}
public static bool GetMouseButtonDown(int button)
{
return Input.GetMouseButtonDown(button) || (button < NUM_MOUSE_BUTTONS && customMouseIsDown[button] && !customMouseWasDown[button]);
}
public static bool GetMouseButton(int button)
{
return Input.GetMouseButton(button) || (button < NUM_MOUSE_BUTTONS && customMouseIsDown[button]);
}
//set custom mouse button states
public static void SetMouseButton(int button, bool isDown)
{
//don't update mouseWasDown state multiple times in one frame
if (lastFrameCustomMouseStateWasSet[button] != Time.frameCount)
customMouseWasDown[button] = customMouseIsDown[button];
//set mouse state for this button
customMouseIsDown[button] = isDown;
//set lastFrame for this button to this frame
lastFrameCustomMouseStateWasSet[button] = Time.frameCount;
}
}
}
Code: Select all
using UnityEngine;
using DaggerfallWorkshop.Game.UserInterface;
public class TestInput : MonoBehaviour
{
private bool isThisMouseDown = false;
private void Update()
{
if (DaggerfallInput.GetMouseButtonDown(0))
Debug.Log("Mouse button down.");
if (DaggerfallInput.GetMouseButtonUp(0))
Debug.Log("Mouse button up.");
if (Input.GetKey(KeyCode.Alpha0))
HoldMouseDown();
else
ReleaseMouse();
}
private void OnDisable()
{
if(isThisMouseDown)
DaggerfallInput.SetMouseButton(0, false);
}
private void HoldMouseDown()
{
isThisMouseDown = true;
DaggerfallInput.SetMouseButton(0, true);
}
private void ReleaseMouse()
{
isThisMouseDown = false;
DaggerfallInput.SetMouseButton(0, false);
}
}
Code: Select all
// Get left and right mouse down for general click handling and double-click sampling
bool leftMouseDown = DaggerfallInput.GetMouseButtonDown(0);
bool rightMouseDown = DaggerfallInput.GetMouseButtonDown(1);
bool middleMouseDown = DaggerfallInput.GetMouseButtonDown(2);
// Get left and right mouse down for up/down events
bool leftMouseHeldDown = DaggerfallInput.GetMouseButton(0);
bool rightMouseHeldDown = DaggerfallInput.GetMouseButton(1);
bool middleMouseHeldDown = DaggerfallInput.GetMouseButton(2);