Search Unity

Oculus translation on "Y" query

Discussion in 'Editor & General Support' started by vertexx, Mar 31, 2014.

  1. vertexx

    vertexx

    Joined:
    Mar 18, 2014
    Posts:
    379
    Absolute beginner here !
    I'm great on 3DSMax but Unity has me confused..But I'm learning bit by bit.
    I have the Oculus headset and viewed many demos.
    I've worked my way through the SDK exercise...Tuscany.

    I noticed that the outcome from the exercise does not allow the user to vary their "height" as they can in the original.???
    The original allows the viewer to adjust their "height" in real time.

    Now am I just too much of a beginner to be able to do this:

    I want to know how to assign a couple of keys so the user can raise and lower their "height" or whatever it's called, interactively during the game.
    Can anyone point out either how this is done or what I need to read?

    Some demo's do allow the viewer to raise and lower their "height" in real time and some don't.
    I'm sure my W7 machine has all the latest and all the required software and hardware to cope.
    Any clues would be greatly appreciated.
     
  2. vertexx

    vertexx

    Joined:
    Mar 18, 2014
    Posts:
    379
    Noticed a hell of a lot of questions are going unanswered.
    Is there a Moderator that can suggest alternate forums or groups that might help.
    Maybe a Beginners Forum might help?

    There will be a lot of 3D artists and modellers coming up that would love to use Unity but as a user and teacher of 3DSMax I must say the Unity manual could be a lot, lot, lot better.
     
  3. chrisall76

    chrisall76

    Joined:
    May 19, 2012
    Posts:
    667
  4. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    633
    Hello, if I understand your question, you're searching for a code snippet to change the position of the player's camera transform?

    Something like :

    Code (csharp):
    1.  
    2. public float verticalSpeed;
    3. public float maxHeight;
    4.  
    5. void Update()
    6. {
    7.     //Check for the key you setup in game controls (set the name and value to whatever suits your need...)
    8.     int dir = Input.Input.GetButton("Vertical");
    9.     if (dir != 0)
    10.     {
    11.          Vector3 tmp = this.transform.localposition; //Gather the position value
    12.          //calculate the new value but check for a max so you don't end up flying unless you want that
    13.          tmp.y = Mathf.min(tmp.y + dir * this.verticalSpeed * Time.delta, this.maxHeight);
    14.          this.transform.localposition = tmp; //then apply the value
    15.     }
    16. }
    17.  
    People answer when they can you know...

    ps: the docs are awsome ;D
     
  5. vertexx

    vertexx

    Joined:
    Mar 18, 2014
    Posts:
    379
    Thanks Met44 for your script and clues!
    Merci very much !!