01-03-2018 05:47 AM
01-03-2018 06:51 AM
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class InputEx : MonoBehaviour {
public float TriggerVal;
public float GripVal;
public Vector2 ThumbStickVal;
public bool IsPoint;
public bool IsThumbsUp;
public enum handedness
{
None = 0,
Left =1,
Right =2,
}
public handedness Handedness;
private OVRInput.Controller m_controllerMask;
void Start()
{
if (Handedness == handedness.Left) {
m_controllerMask = OVRInput.Controller.LTouch;
}
if (Handedness == handedness.Right) {
m_controllerMask = OVRInput.Controller.RTouch;
}
}
void Update () {
AnalogInputUpdate ();
DigitalInputUpdate ();
}
void AnalogInputUpdate()
{
if (Handedness == handedness.Left) {
TriggerVal = OVRInput.Get (OVRInput.RawAxis1D.LIndexTrigger);
GripVal = OVRInput.Get (OVRInput.RawAxis1D.LHandTrigger);
ThumbStickVal = OVRInput.Get (OVRInput.Axis2D.PrimaryThumbstick);
}
else if (Handedness == handedness.Right) {
TriggerVal = OVRInput.Get (OVRInput.RawAxis1D.RIndexTrigger);
GripVal = OVRInput.Get (OVRInput.RawAxis1D.RHandTrigger);
ThumbStickVal = OVRInput.Get (OVRInput.Axis2D.SecondaryThumbstick);
}
}
void DigitalInputUpdate()
{
//capacitive point and thumbs up
IsPoint = !(OVRInput.Get (OVRInput.Touch.PrimaryIndexTrigger, m_controllerMask));
IsThumbsUp = !OVRInput.Get(OVRInput.NearTouch.PrimaryThumbButtons, m_controllerMask);
//digital buttons down
if (OVRInput.GetDown (OVRInput.RawButton.X , m_controllerMask)) {
Debug.Log ("X Down");
}
if (OVRInput.GetDown (OVRInput.RawButton.Y , m_controllerMask)) {
Debug.Log ("Y Down");
}
if (OVRInput.GetDown (OVRInput.RawButton.A , m_controllerMask)) {
Debug.Log ("A Down");
}
if (OVRInput.GetDown (OVRInput.RawButton.B , m_controllerMask)) {
Debug.Log ("B Down");
}
if (OVRInput.GetDown (OVRInput.RawButton.Start , m_controllerMask)) {
Debug.Log ("Menu Button Down");
}
//digital buttons up
if (OVRInput.GetUp (OVRInput.RawButton.X , m_controllerMask)) {
Debug.Log ("X Up");
}
if (OVRInput.GetUp (OVRInput.RawButton.Y , m_controllerMask)) {
Debug.Log ("Y Up");
}
if (OVRInput.GetUp (OVRInput.RawButton.A , m_controllerMask)) {
Debug.Log ("A Up");
}
if (OVRInput.GetUp (OVRInput.RawButton.B , m_controllerMask)) {
Debug.Log ("B Up");
}
if (OVRInput.GetUp (OVRInput.RawButton.Start , m_controllerMask)) {
Debug.Log ("Menu Button Up");
}
}
}
03-13-2018 10:22 AM
MikeF said:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class InputEx : MonoBehaviour {
public float TriggerVal;
public float GripVal;
public Vector2 ThumbStickVal;
public bool IsPoint;
public bool IsThumbsUp;
public enum handedness
{
None = 0,
Left =1,
Right =2,
}
public handedness Handedness;
private OVRInput.Controller m_controllerMask;
void Start()
{
if (Handedness == handedness.Left) {
m_controllerMask = OVRInput.Controller.LTouch;
}
if (Handedness == handedness.Right) {
m_controllerMask = OVRInput.Controller.RTouch;
}
}
void Update () {
AnalogInputUpdate ();
DigitalInputUpdate ();
}
void AnalogInputUpdate()
{
if (Handedness == handedness.Left) {
TriggerVal = OVRInput.Get (OVRInput.RawAxis1D.LIndexTrigger);
GripVal = OVRInput.Get (OVRInput.RawAxis1D.LHandTrigger);
ThumbStickVal = OVRInput.Get (OVRInput.Axis2D.PrimaryThumbstick);
}
else if (Handedness == handedness.Right) {
TriggerVal = OVRInput.Get (OVRInput.RawAxis1D.RIndexTrigger);
GripVal = OVRInput.Get (OVRInput.RawAxis1D.RHandTrigger);
ThumbStickVal = OVRInput.Get (OVRInput.Axis2D.SecondaryThumbstick);
}
}
void DigitalInputUpdate()
{
//capacitive point and thumbs up
IsPoint = !(OVRInput.Get (OVRInput.Touch.PrimaryIndexTrigger, m_controllerMask));
IsThumbsUp = !OVRInput.Get(OVRInput.NearTouch.PrimaryThumbButtons, m_controllerMask);
//digital buttons down
if (OVRInput.GetDown (OVRInput.RawButton.X , m_controllerMask)) {
Debug.Log ("X Down");
}
if (OVRInput.GetDown (OVRInput.RawButton.Y , m_controllerMask)) {
Debug.Log ("Y Down");
}
if (OVRInput.GetDown (OVRInput.RawButton.A , m_controllerMask)) {
Debug.Log ("A Down");
}
if (OVRInput.GetDown (OVRInput.RawButton.B , m_controllerMask)) {
Debug.Log ("B Down");
}
if (OVRInput.GetDown (OVRInput.RawButton.Start , m_controllerMask)) {
Debug.Log ("Menu Button Down");
}
//digital buttons up
if (OVRInput.GetUp (OVRInput.RawButton.X , m_controllerMask)) {
Debug.Log ("X Up");
}
if (OVRInput.GetUp (OVRInput.RawButton.Y , m_controllerMask)) {
Debug.Log ("Y Up");
}
if (OVRInput.GetUp (OVRInput.RawButton.A , m_controllerMask)) {
Debug.Log ("A Up");
}
if (OVRInput.GetUp (OVRInput.RawButton.B , m_controllerMask)) {
Debug.Log ("B Up");
}
if (OVRInput.GetUp (OVRInput.RawButton.Start , m_controllerMask)) {
Debug.Log ("Menu Button Up");
}
}
}Attach to gameobject, select handedness, run.
Hey, thanks so much for the response. I tried for 70 days since you posted to understand what you have typed and make it work. But I have had zero luck. I will list my simple steps (I'm trying to get it to work on a CUBE before anything 'complex' (joke..) 🙂
1) I create a New Unity Project and import Oculus Utilities.
2) I create a cube, I drag in OVR Camera Rig make it a child of the cube..
3) I select Cube, add component New Script and paste in your text in Visual Studio. I save the file as fly.cs
4) I set player setting for VR Enabled and Oculus (No open VR)
5) I run the game window, try every single button and grips etc on each oculus controller, Nothing at all,.
So, That's where i'm at, 70 days of trying over and over, trying everything,.. (well except the once thing I'm missing I guess LOL) I look at the Cube inspector, it does say at the top of the Script Component entry 'NOTHING SELECTED' (???) The CUBE IS SELECTED!! The errors I get are:
1) The referenced script on this Behaviour is missing! (referenced Script? I only have ONer Script and it IS the fly.cs Script! ????? It is Definately in the Project FOlder, That where I created directly ONTO the cube,..)
2) The referenced script on this Behaviour (Game Object 'Cube') is missing!Thanks for trying. But it does not run. It does not run.I'm no dunce, I worked in CGI for 25 years in Hollywood, since the DOS days, 3D STUDIO R1 for DOS!! I was Technical Director of an Animatoed TV show on Playboy TV, ( in the early 1990's!) Ore recently, I worked on 'LIFE of PI'! I build computers, replace and update CCFL's in monitors with LEDS< I solder blown Capacitors, I compose 100-piece orchestral scores digitally, I can make any impossible thing happen visually with CGI, compositing, editing, special effects. I play Violin, Cello, Piano,. and my main talent: I am a Master Character Animator of the highest order for 23 years. <---- I only say this to point out the fact the fault is NOT in ME, it is with UNITY and their inability to GIVE GOOD CONCISE INSTRUCTION to OTHER Types of people than the typical, Left Brained Programmer Non-Artists.
RANT:
I HAVE TRIED TO LEARN UNITY FOR .. AS LONG AS IT HAS EXISTED. THE SIMPLEST THING LiKe THIS LOCOMOTION PROBLEM, THAT I CONTINUE TO BATTLE FOR, CAN TAKE AS LONG AS A year TO GET ANY HELP ON, AND THAT HELP WHEN IT COMES, IS USUALLY JUST, SOME UNEXPLAINED, //non commented, NON-WOKRING CODE WITH SOMETHING GLIB 'INSTRUCTION' LIKE: 'SIMPLY ATTACH TO OBJECT AND RUN!"
I WOULD SAY, IT'S NO WONDER SO FEW REAL ARTISTS, CHARACTER ANIMATORS, FILMMAKERS, MUSICIANS LIKE MYSELF, ARE MAKING VR GAMES!! ( OR INTERACTIVE FEATURE FILMS,..)
We get the same 'stand in the middle of a room and shoot at things' VR apps OVER and OVER,.
I'm not embarrassed in the slightest. I can figure ANYTHING out INSTANTLY with good source material. , There has NEVER in 20 years, been anything good to learn UNITY, and the few things I found that seemed ok, WERE COMPLETELY WRONG and unusable because EVERYTHING IN UNITY had changed between micro-sub-point incremental updates, making it irrelevant.( and actually HARMFUL)
This interactive stuff is so much heartache, hair pulling, the worst thing I have ever done on my life and I'm a Cancer survivor,. IT's NOT AT ALL FUN IN ANY WAY SHAPE OR FORM, JUST AN ENDLESS NIGHTMARE .
At least my stupid Human 'optimism bias' is finally dead.. I don't even HOPE any more..
03-13-2018 10:39 AM
MikeF said:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class InputEx : MonoBehaviour \ (ETC....)
Attach to gameobject, select handedness, run.
Hey Mike, thanks so much for the response. I have literally tried to make this work for 70 days since you posted (not wanting to post back until I figured it out, but,.... That single sentence of 'instruction', pretty much doomed me to fail,...)It took me over 30 days just to ALMOST RANDOMLY figure out because you called the Public Class InputEx, I have to call the cs file InputEx.
'Name the cs file InputEx.cs' That simple line would have saved me 34 days and gotten my App into Dashboard.
I will list my simple steps.
1) I create a New Unity Project and import Oculus Utilities.
2) drag in OVR Character Controller (and tried on a OVR Camera Rig).
3) I add component New Script to the OVR Prefab, and paste your text in Visual Studio. I save the file as InputEx.cs
4) I set player setting for VR Enabled and Oculus (No open VR)
5) I run the game window, try every single button and grips etc on each oculus controller, Nothing at all,. Some number and Checkboxes in the INSPECTOR Change,. If I knew what to DO with that I'm sure it would be VERY HELPFUL, But it means nothing,. Just numbers changing,. Was I supposed to have an epiphany?,.. It might have been nice to say WHAT YOU WERE HANDING ME!! I asked for help FLYING,.. I only got changing numbers,..
So that's where i'm at,. I guess my new question is :
HOW DO I USE CHANGING NUMBERS IN INSPECTOR TO FLY. I never seem to get ahead in Unity. THIS IS JUST NOT FUN. Nearly everything else in my 26 year CGI Career has been so much fun, but this is like pulling razor-wire-teeth with a red hot poker...
Is is SO BAD to be an Artist, Musician and Character Animator, and want to make APPS? Does the community have to PUNISH ARTISTS and CHARACTER ANIMATORS merely for having a DIFFERENT SPECIALITY????,
It would be nice to have someone make something DIFFERENT, WOULDN'T It??? I would LOVE to STOP LAUGHING at the CHARACTERS I see in VR. Not one well done to date. I suspect other Character Animators like myself, couldn't break thought the sullen, insular, CLIQUE that are these awful, UGLY, SOUL DRAINING,. FORUMS.
SO, more and more apps where one: STANDS IN THE MIDDLE OF A ROOM AND SHOOTS AT THINGS.
JOY.