Week 4: Handling Camera Movement in VR

FOV.jpg

I am facing a problem in Museum Multiverse, the third person camera still feels weird following the player. I want to make sure the movement is smooth and comfortable for the camera and player, so I have been looking around for solutions and I think I found one.

Limiting the player’s peripheral view reduces the motion sickness of movement. I learned this from a paper I found on the subject by Ajoy S Fernandes and Steven K. Feiner at Columbia University. Basically the solution they learned from experimentation had a real reduction of motion sickness by limiting the view based on player speed.

So how do we do this in Unity?

First we would need to import the older Image Effects into Unity from the asset store. We are really just looking for the Vignette And Chromatic Aberration script. After you import this add this to your main camera. Once this script is added you need to set everything on the script to 0, you will only be playing around with the vignetting option.

Screen Shot 2017-07-09 at 3.11.17 PM.png

Try playing around with the Vignetting values to see how it effects your camera!

Screen Shot 2017-07-09 at 3.14.53 PM.png

Next we are going to write a script to adjust the Vignetting based of the Camera speed.

using System.Collections;
using System.Collections.Generic;
using UnityStandardAssets.ImageEffects;
using UnityEngine;

public class FOVLimiter : MonoBehaviour {
    private Vector3 oldPosition;
    public float MaxSpeed = 6f;
    public float MaxFOV = .7f;

    public static float CRate = .01f;
    public static float RateCutOff = .25f;

    // max .7 Vignetting

    private VignetteAndChromaticAberration fovLimiter;
    // Use this for initialization
    void Start () {
        oldPosition = transform.position;
        fovLimiter = GetComponent<VignetteAndChromaticAberration> ();
    }
    
    // Update is called once per frame
    void Update () {
        Vector3 velocity = (transform.position  oldPosition) / Time.deltaTime;
        oldPosition = transform.position;

        float expectedLimit = MaxFOV;
        if (velocity.magnitude < MaxSpeed) {
            expectedLimit = (velocity.magnitude / MaxSpeed) * MaxFOV;
        }

        float currLimit = fovLimiter.intensity;
        float rate = CRate;

        if (currLimit < RateCutOff) {
            rate *= 3; //fast rate since the field of view is large and fast changes are less noticeable
        } else {
            rate *= .5f; //slower rate since the field of view changes are more noticable for larger values. 
        }

        fovLimiter.intensity = Mathf.Lerp (fovLimiter.intensity, expectedLimit, rate);
    }
}

So what the heck is the Field Of Vision (FOV)Limiter script is doing? We are grabbing the distance the player has traveled each frame to find the speed of the player and calculate how much of the field of vision should be limited based on the player speed. So remembering some key points from the paper, the rate of the FOV transition can be faster at some points when the field of view is large because fast changes are less noticeable, but FOV changes are more noticeable for larger values.

Right now this is working pretty well but I know this is only step one to making a great 3rd person VR camera. Next week I will be focusing on making a smarter camera that can follow the player without getting stuck on walls.

If you would like to learn more about limiting camera view to prevent motion sickness and other VR tips I would recommend checking out FusedVR these guys are great!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s