Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Simple C# Oculus Rift 'Touch' input question... (LOL) (BEEN ASKING FOR OVER 46 DAYS!!)

Discussion in 'General Discussion' started by NextWorldVR, Jan 6, 2018.

Thread Status:
Not open for further replies.
  1. NextWorldVR

    NextWorldVR

    Joined:
    Dec 30, 2017
    Posts:
    14
    Hello,
    I have a UNITY Prefab model I am learning from called AircraftJet.

    I simply want to use Oculus Rift Touch instead of Mouse and Keyboard. This is what the relevant section of code looks like:

    private void FixedUpdate()
    {
    // Read input for the pitch, yaw, roll and throttle of the aeroplane.

    // Roll: I want to make the Left Horizontal Thumbstick
    float roll = CrossPlatformInputManager.GetAxis("Mouse X");

    // Pitch: I want to make the Right Vertical Thumbstick
    float pitch = CrossPlatformInputManager.GetAxis("Mouse Y");

    // YAW: I want to make Right horizontal Thumbstick
    m_Yaw = CrossPlatformInputManager.GetAxis("Horizontal");

    // Throttle: I want to make the right Trigger
    m_Throttle = CrossPlatformInputManager.GetAxis("Vertical");

    // Air Brakes: I want to be able to just let off the thrust, OR Airbrakes left trigger
    m_AirBrakes = CrossPlatformInputManager.GetButton("Fire1");

    #if MOBILE_INPUT
    AdjustInputForMobileControls(ref roll, ref pitch, ref m_Throttle);
    #endif
    // Pass the input to the aeroplane
    m_Aeroplane.Move(roll, pitch, m_Yaw, m_Throttle, m_AirBrakes);
    }

    HOW DO I ADAPT THIS SORT OF METHOD (ABOVE) TO USE OCULUS RIFT TOUCH?

    I ASKED OCULUS FOR A TINY BIT OF HELP TO SHOW ME WHAT MY CODE ABOVE WOULD LOOK LIKE IF ADAPTED FOR OCULUS, SO I COULD THEN USE IT TO TEACH MY NEARLY 2,000 YOUTUBE SUBSCRIBERS,. . Oculus sent me back me this pithy clue:

    leftThumbstickPosition = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick)
    rightThumbstickPosition = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick)
    leftTrigger = OVRInput.Get(OVRInput.Axis1D.SecondaryIndexTrigger);
    rightTrigger = OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger);
    roll = leftThumbstickPosition.x
    pitch = rightThumbstickPosition.y
    m_Yaw = rightThumbStickPosition.y
    m_Throttle = rightTrigger;
    m_AirBrakes = leftTrigger;

    BUT THAT didn't help at all...... of course. As I am learning to program and I learn best by reverse engineering, (ALAS I HAVE NO REAL WORLD BEFORE / AFTER OCULUS CODE TO WORK FORM,.. )
    Sending me that as an answer was like a slap in the face, it's like they are more interested in SHAMING PEOPLE for not being perfect programmers, than getting ARTISTS to add new content to the OCULUS STORE!

    WE CGI WIZARDS OF THE 90'S AND 2000'S WOULD NEVER HAVE MADE IT THIS HARD FOR A YOUNG CGI ARTIST. WE SHARED.


    I'm sure no one will look but here below, is the complete UNITY supplied Tutorial Code. Eventhogh I am a disabled Artist rebuilding my career I would PAY someone to convert this to use Rift so I can finally see what the difference is an MOVE ON WITH MY WORK....

    i have wasted months, literally months trying to figure this simple thing above out!!!
    There is no way to get there from here, if you don't already know how, a catch 22. and no one I MEAN NO ONE will help anyone anymore! Maybe people think the world is ending and just don't care anymore;

    IF SOMEONE CONVERTS THIS FOR USE WITH OCULUS RIFT ( I ADDED COMMENTS WHAT I AM TRYING TO ACCOMPLISH) I WILL USE IT MYSELF TO TEACH MY NEARLY 2,000 VR INTERESTED YOUTUBE SUBSCRIBERS.
    -------------------------------------------------------------------------------------------------------------------------------------------

    using System;
    using UnityEngine;
    using UnityStandardAssets.CrossPlatformInput;

    namespace UnityStandardAssets.Vehicles.Aeroplane
    {
    [RequireComponent(typeof (AeroplaneController))]
    public class AeroplaneUserControl4Axis : MonoBehaviour
    {
    // these max angles are only used on mobile, due to the way pitch and roll input are handled
    public float maxRollAngle = 80;
    public float maxPitchAngle = 80;

    // reference to the aeroplane that we're controlling
    private AeroplaneController m_Aeroplane;
    private float m_Throttle;
    private bool m_AirBrakes;
    private float m_Yaw;


    private void Awake()
    {
    // Set up the reference to the aeroplane controller.
    m_Aeroplane = GetComponent<AeroplaneController>();
    }


    private void FixedUpdate()
    {
    // Read input for the pitch, yaw, roll and throttle of the aeroplane.

    // Roll: I want to make the Left Horizontal Thumbstick
    float roll = CrossPlatformInputManager.GetAxis("Mouse X");

    // Pitch: I want to make the Right Vertical Thumbstick
    float pitch = CrossPlatformInputManager.GetAxis("Mouse Y");

    // YAW: I want to make Right horizontal Thumbstick
    m_Yaw = CrossPlatformInputManager.GetAxis("Horizontal");

    // Throttle: I want to make the right Trigger
    m_Throttle = CrossPlatformInputManager.GetAxis("Vertical");

    // Air Brakes: I want to be able to just let off the thrust, OR Airbrakes left trigger
    m_AirBrakes = CrossPlatformInputManager.GetButton("Fire1");

    #if MOBILE_INPUT
    AdjustInputForMobileControls(ref roll, ref pitch, ref m_Throttle);
    #endif
    // Pass the input to the aeroplane
    m_Aeroplane.Move(roll, pitch, m_Yaw, m_Throttle, m_AirBrakes);
    }


    private void AdjustInputForMobileControls(ref float roll, ref float pitch, ref float throttle)
    {
    // because mobile tilt is used for roll and pitch, we help out by
    // assuming that a centered level device means the user
    // wants to fly straight and level!

    // this means on mobile, the input represents the *desired* roll angle of the aeroplane,
    // and the roll input is calculated to achieve that.
    // whereas on non-mobile, the input directly controls the roll of the aeroplane.

    float intendedRollAngle = roll*maxRollAngle*Mathf.Deg2Rad;
    float intendedPitchAngle = pitch*maxPitchAngle*Mathf.Deg2Rad;
    roll = Mathf.Clamp((intendedRollAngle - m_Aeroplane.RollAngle), -1, 1);
    pitch = Mathf.Clamp((intendedPitchAngle - m_Aeroplane.PitchAngle), -1, 1);
    }
    }
    }
     
  2. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Perhaps it wouldn't be 46 days plus if one would entertain the notions of:
    • using code tags and using clear formatting
    • being bothered to post in the correct section of the forum
    • being coherent - post is gibberish
    Your post is incredibly immature. You decided to attack Oculus for helping you, so I do not think many people will feel encouraged to help you either over here.
     
    Socks, Amon, QFSW and 6 others like this.
  3. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    When people see a crazy person in the street, they go to the other side.
     
  4. Braineeee

    Braineeee

    Joined:
    Nov 9, 2014
    Posts:
    1,211
    Now hold up everyone if you'd have bothered to read this guys entire post, you would know that they are disabled.

    Like others have said, please try to surround your code with [ CODE ] tags. Second I know that you are frustrated however a little kindness and patience will go a long ways.

    I am not familiar with VR, so I can't exactly help here though.
     
  5. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,091
    Being disabled isn't an excuse to not follow the rules. For the record I'm disabled too but you don't see me breaking them.
     
  6. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,732
    I'm disabled and I break all the rules but that's okay because I'm also cool as heck.
     
    theANMATOR2b and Amon like this.
  7. Amon

    Amon

    Joined:
    Oct 18, 2009
    Posts:
    1,361
    Pay me £2000 and I will do this for you. I want the £2000 upfront because of your attitude.
     
    Socks likes this.
  8. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,383
    Maybe programming isn't for you.
     
    Amon and Socks like this.
Thread Status:
Not open for further replies.