Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Help with Mirroring Oculus Controllers

Discussion in 'VR' started by Afroca, Jul 11, 2019.

  1. Afroca


    May 24, 2019
    Currently I am trying to write a script that will mirror the movements of one controller onto the other for users who only have 1 functioning arm. Mirroring the y axis and z axis were easy since they move together and the rotation was easy to mirror. I am unable to mirror the x axis movement. I want it so that if the one hand moves out the other does the same, and they both move in together. Any ideas how I may be able to do this? I have attached my current script.

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class VRMirror : MonoBehaviour
    public bool mirrorLeft;
    public bool mirrorRight;
    public GameObject leftHand;
    public GameObject rightHand;
    void Start()

    void FixedUpdate()
    Transform left = leftHand.GetComponent<Transform>();
    Transform right = rightHand.GetComponent<Transform>();
    if (mirrorLeft)
    Vector3 leftPos = left.position;
    Quaternion leftRot = left.rotation;
    leftRot.y = -leftRot.y;
    right.position = leftPos;
    right.rotation = leftRot;
    else if (mirrorRight)
    Vector3 rightPos = right.position;
    Quaternion rightRot = right.rotation;

    rightRot.y = -rightRot.y;
    left.position = rightPos;
    left.rotation = rightRot;


    Attached Files: