Complete and utter newbie here that’s trying to shoot for something that’s probably outta my league, but it’s my assigned task so here we go. Any help is much appreciated.
To describe the overall situation, our project is creating a virtual set and being able to view a scene in VR, with a pop up display that allows you to view parts of the scene through different cameras with different lenses, for cinematic purposes. Since the default method of implementing a HUD doesn’t integrate well with the VR, I’ve created a plane with a render texture of a second camera in the scene. To achieve proper angles from the perspective of the player, however, I’d like for it to mimic the orientation of the VR perspective itself.
I’m trying to basically make a second camera, separate from the MainCamera (which is the VR perspective attached to a RigidbodyFPSController), attach and follow the player’s perspective as well as mirror the rotations and movements of the VR perspective as well. I’ve tried attaching the camera as a child of the MainCamera and while that worked to some degree, it gave the secondary camera high amounts of strange shaking and jittering (especially when looking down). I then tried to make it a child of the Rigidbody controller. While the movement was smoother, it didn’t follow the headset tracking. I then opted to make a third person follow script based on a tutorial, but this provided me with a camera that couldn’t rotate (and by extension, didn’t follow the VR movement at all). The script I used is as follows:
public class ThirdPersonCam : MonoBehaviour
public Transform lookAt;
public Transform camTransform;
private Camera cam;
private float distance = 5.0f;
private float currentX = 0.0f;
private float currentY = 0.0f;
private float sensivityX = 4.0f;
private float sensivityY = 1.0f;
private void Start()
camTransform = transform;
cam = Camera.main;
private void LateUpdate()
Vector3 dir = new Vector3(0, 0, -distance);
Quaternion rotation = Quaternion.Euler(currentY, currentX, 0);
camTransform.position = lookAt.position + rotation * dir;
I figured that I might be able to better use this script if I figured out what the input was classified as in the system for the HTC Vive’s head tracking, but I’m not even sure if that’s feasible. So… I’m kinda at a loss here in my inexperience, so I’m hunting for advice or solutions. Is there actually a way for me to tell the secondary camera to move according to the values given by the tracking of the Vive, or some form of workaround that can grant something close to this effect? I thought of maybe making it the child of the Rigidbody and then using a script to make it mirror the MainCamera values but I don’t even know where to begin in that regard.