Search Unity

[Solved] Rotation issue with simple VR torso "simulation"

Discussion in 'Scripting' started by Tjen, Jan 8, 2017.

  1. Tjen

    Tjen

    Joined:
    Jan 8, 2017
    Posts:
    5
    Hi guys. long time listener, first time caller :)

    After working on my latest project I really felt how big of a help this forum was as a resource, so I thought I would contribute to its 'library' so that others might find the answer for this one.

    There are many things I can do, but understand rotations I would not claim to be one of them.

    I am making a VR game and I would love to be able to store items on my body. To this end I am making a simulated chest and I only need it to do a few simple things:

    1. Face the ground
    2. Face the direction that the headset is facing


    Nice to have, but totally not needed is to smooth out the last part to simulate you being able to turn your head without your body instantly snapping to it.

    Step 2 is solvable for me, I just use a "this.transform.LookAt(Vector3.up);"

    Here is how my intended set up looks:



    The two pink boxes are your hips where you can draw your swords and gadgets from.

    Long story short. If anyone has a good idea of how to make it both face the parents look direction but also constrain it to always be facing the ground, preferably in a simple way I would be one happy camper.

    Thanks in advance!

    - Tom
     
  2. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
    Hope this helps!

     
    Tjen likes this.
  3. Tjen

    Tjen

    Joined:
    Jan 8, 2017
    Posts:
    5
    Cheers for that :)

    I think I should be able to extrapolate it to fit my situation.

    The part that I really wanted to know is the one where a 3rd party script is used :D guess I'll have a look through that script and see if my understanding of rotations will improve after that.

    Time will tell hehe

    Thanks again!
     
    Last edited: Jan 8, 2017
  4. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
  5. Tjen

    Tjen

    Joined:
    Jan 8, 2017
    Posts:
    5
    Just wanted to let you know that it helped. I was locked in one way of thinking, and watching that video inspired me to do it in a similar way. I ended up using iTween too as it was super easy to get the result I was looking for.

    Thanks again, much appreciated :)

    Now my sword and bucklers stay at my hip, ready to grab when I have to put down my bow :D
     
    Selzier likes this.