last day (25 days later) » 

Sie
Sie
20:36
Hey. So I did some moving around and got it kind of working. Key word kind of.
Hey man, what's up?
Sie
Sie
using UnityEngine;
using System.Collections;
using Valve.VR;
using System;

public class WandController : MonoBehaviour {
    private Valve.VR.EVRButtonId gripButton = Valve.VR.EVRButtonId.k_EButton_Grip; //Essentially this is accessing
                                                                                   //SteamVR_TrackedObject.cs and telling our script
                                                                                   //and defining it here.


    private Valve.VR.EVRButtonId triggerButton = Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger;
What's the compiler giving you now?
Sie
Sie
See this line? "if (rightDevice.GetTouch(SteamVR_Controller.ButtonMask.Touchpad))". Well when I changed from device to rightDevice to get input only from that controller the editor started giving some errors at runtime.
get_frameCount can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Which was a reference to SteamVR_Controller.cs on line 60.
//========= Copyright 2015, Valve Corporation, All rights reserved. ===========
//
// Purpose: Wrapper for working with SteamVR controller input
//
// Example usage:
//
//	var deviceIndex = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Leftmost);
//	if (deviceIndex != -1 && SteamVR_Controller.Input(deviceIndex).GetPressDown(SteamVR_Controller.ButtonMask.Trigger))
//		SteamVR_Controller.Input(deviceIndex).TriggerHapticPulse(1000);
//
//=============================================================================
here is the pastebin version: pastebin.com/u1PhwxJu
Oh yeah, which thread is WandController running on?
Sie
Sie
20:39
I'm assuming it runs all on one core? I might be mistaken. I've only played with high level stuff.
Oh, have you tried moving rightDevice and leftDevice into private fields on your class?
Unity inherently splits things up
private SteamVR_Controller.Device rightDevice = SteamVR_Controller.Input(rightIndex);
private SteamVR_Controller.Device leftDevice = SteamVR_Controller.Input(leftIndex);
in the class, that might make it run on the loading thread
Sie
Sie
I was just doing that.
It doesn't like that. "A field initializer cannot reference the non-static field, method, or property 'WandController.rightIndex'".
Oh yeah, what you'd have to do is:
SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Rightmost)
private SteamVR_Controller.Device rightDevice = SteamVR_Controller.Input(rightIndex);
sorry, auto sent the message
private SteamVR_Controller.Device rightDevice = SteamVR_Controller.Input(SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.De‌​viceRelation.Rightmost));
It looks a little verbose, but that will fix the issue
Sie
Sie
Just a sec.
Unity is being a pita.
Yeah man, I understand that, Unity and C# can be a pain
Sie
Sie
20:45
Eh. Unity has somehow decoupled itself with VS.
What I mean is the errors will show up in console but VS will not "see" them.
"Unexpected symbol `<internal>' in class, struct, or interface member declaration" is what Unity is saying in the output but in VS it looks fine to me and the error console (ie no errors).
Ok I just reset both of them and now the error is magically gone.
Brilliant.
The same errors are back though unfortunately.
get_frameCount can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
That is on line 60.
Ya @Matt it really doesn't like being called from anything but the main thread apparently.
:/
Hmm.. it's odd that it will allow the other device but not left and right
Oh!
Idea
private SteamVR_Controller.Device rightDevice = { get { return SteamVR_Controller.Input(SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.De‌​viceRelation.Rightmost)); } }
How about that?
Sie
Sie
Testing now.
I think the formatting on that is busted. I tried moving them but it doesn't care for it.
private SteamVR_Controller.Device rightDevice = { get { return SteamVR_Controller.Input(SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.De‌​‌​viceRelation.Rightmost) } };
No, it's a block getter, no simicolons after required, but inside the block they are
It's a missing ); at the end of Rightmost)
Sie
Sie
I just went back and tried your original code and no dice still.
I added an extra ) where you said and that just added another syntax error.
ffs
Never had this issue before with Unity or C#.
Why does it care so much about which thread it's running on?
21:01
No no, that's good
Because, race conditions
it would crash if it accessed that memory
private SteamVR_Controller.Device rightDevice = { get { return SteamVR_Controller.Input(SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.De‌​viceRelation.Rightmost)); } }
that code exactly, on one line
Sie
Sie
Oh well I guess it's just doing it's job in that case...
does that cause a syntax error?
Sorry, I meant this:
private SteamVR_Controller.Device rightDevice { get { return SteamVR_Controller.Input(SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.De‌​viceRelation.Rightmost)); } }
that's what you want
That exactly should work
Sie
Sie
No that worked.
I think chat formatting was fucking something up.
Woo, so that should use a lock getter so it should work on the right thread
Sie
Sie
Nope. Same slew of errors as before.
21:05
Screenshot?
Sie
Sie
Sure. Sec.
btw really appreciate the help with this up until now
Alright.
Absolutely man, hopefully I can get it working for you
Sie
Sie
There are a few unrelated errors in there but feel free to ignore those. Just a save thing.
I gotta eat diner. I will be back in like 20 min.
Okay man, I'll do some research
21:18
I figured it out mate, you just have to move everything that must be called on the main thread to Start
private SteamVR_Controller.Device rightDevice;
and then in Start():
rightDevice = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.De‌​viceRelation.Rightmost));
Sie
Sie
21:31
So close.
Cannot implicitly convert type 'int' to 'SteamVR_Controller.Device'
No worries, I didn't copy the whole thing
I meant:
rightDevice = SteamVR_Controller.Input(SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.De‌​viceRelation.Rightmost));
Sie
Sie
Well closer now.
It let me run nit but then it gave more errors. Screenshot coming.
Could you send a snippet of the WandController's properties?
Like all of the private properties on the class
Sie
Sie
Sure.
It's the same issue, so we'd need to move every private property from the class declaration to the Start method
Sie
Sie
21:46
Christ. This seems like it's much harder than it should be.
Here you go:
private Valve.VR.EVRButtonId gripButton = Valve.VR.EVRButtonId.k_EButton_Grip; //Essentially this is accessing
//SteamVR_TrackedObject.cs and telling our script
//and defining it here.


private Valve.VR.EVRButtonId triggerButton = Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger;
private Valve.VR.EVRButtonId Touchpad = Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad;

private SteamVR_Controller.Device controller { get { return SteamVR_Controller.Input((int)trackedObj.index); } }
private SteamVR_TrackedObject trackedObj;
Oh trust me mate, Unity makes it a bit easier, I have about 20,000 lines of C++ just wrapping OpenVR
private SteamVR_Controller.Device controller { get { return SteamVR_Controller.Input((int)trackedObj.index); } }
that's the line that is causing the issue
since you shoulding be using it in the Update now that you have rightDevice, just comment or delete the line
Sie
Sie
Well I just commented it out for good measure and it goes back to that same default error.
default error?
Sie
Sie
> Unexpected symbol `<internal>'
On this: rightDevice = SteamVR_Controller.Input(SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.De‌​‌​viceRelation.Rightmost));
Can you send me visual studio screenshot of the error and what line it highlights?
Sie
Sie
21:50
on line 55, replace controller with rightDevice
and any where else controller shows up with a red line under it, replace with rightDevice
Sie
Sie
Same error.
Yes, but different location, double click the error where visual studio shows it and it should highlight the offending line
Sie
Sie
> rightDevice = SteamVR_Controller.Input(SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.De‌​‌​viceRelation.Rightmost));
2 mins ago, by Sie
user image
That's not the line, Visual Studio would highlight it with red if there was an error there; recompile and then send a screenshot of the build output (errors)
I know it can be frustrating getting into C# and MS Visual Studio
Sie
Sie
21:56
Well that's the line Unity is taking issue with.
:/
What's the error that Unity is throwing now?
Sie
Sie
Unexpected symbol `<internal>'.
Can you show me a screenshot of what window that error is coming from?
I got an idea
Sie
Sie
22:00
I
I'm up for whatever.
I'm typing it up now, I'll send it over in a minute
Sie
Sie
k
I sent a Github Gist because it was easier to preserve code formatting than StackChat
Sie
Sie
Moar errors.
Moth of christ it never ends lol.
No no this is good, it revealed the true error
Sie
Sie
22:10
the true error?
lol
Now there is a false prophet error.
Bad jokes aside I think you can tell I like the design side of things more than the code :P.
Yeah man, I've been a programmer for 12 years now, so this stuff is fun for me
Are you using MotionControl anywhere?
Sie
Sie
I don't mind it but it does aggravate me after awhile.
MotionControl and trackedObject are the same thing with two names
Sie
Sie
It is null apparently.
Controller not initalized
Sie
Sie
22:12
Shouldn't it be getting detected?
then lets comment out the declaration of MotionControl and trackedObject and replace it with rightDevice
or you could send me the entire WandController.cs and I could fix any issues I see with it and clean it up so it's a little simpler?
Sie
Sie
Sure. I appreciate it.
Absolutely man, just give me a few minutes and I'll send something over
Now, this still might have some final things to fix, but at least now it isn't trying to use things that will permanently be null
Sie
Sie
Thank you so much. It's finally working semi-properly now.
What a pain that was. Really appreciate the help though :).
Why'd you stop coming to the main room btw?
Absolutely man!
Oh I've just been busy as hell with my dayjob and working on a horror game
Sie
Sie
22:24
Ah I get that. Horror game? I like horror games. What kind?
Right now, it's turned into a kind of fleeing a hostile state
As in, you're stuck in a small country controlled by an evil military influenced by demons
I'm just playing around with the ideas, but it's creepy as hell with bugs
Sie
Sie
Hmm. Is it like an action game kind of? I kind of tend to go for slower more atmospheric horror games like Soma, Amnesia and Penumbra.
No, it's more like Amnesia in the woods where the enemy has guns and you have to evade and survive
Sie
Sie
Sounds cool :).
You set up traps with the environment and you make them patrol themselves to their own death
haha
Sie
Sie
22:27
Anyway I've gotta get some other stuff done. Thanks a bunch.
Absolutely man! Have a great day
Sie
Sie
yep you too

  last day (25 days later) »