Dissecting Proton Pulse - Move the Paddle
I've been getting quite a few questions in regards to how things work in Proton Pulse Rift. I thought I would give brief examples on how I put things together in these threads to share the knowledge.
There is no guarantee that the knowledge given here is worth anything. Use at your own discretion. :lol:
Moving the Paddle with Head Tracking
The paddle follows your head movements on the X and Y axis, but remained Z locked.
This is quite easy actually. First, you need to create a child object in the "CameraLeft" in the OVRCameraController prefab provided by the Oculus VR Unity Integration. We will call this the "Follower Object". Place the Follower Object in front of the camera as far out as you need to give the object following it the full range it needs.
Now place the object you want to follow your movements into the scene (EX: a Paddle).
Apply the following script in C# to the Paddle object:
With the Paddle Object selected, click / drag the Follower Object into the "Follow Object" slot in the inspector. Now check "X" and "Y" but leave "Z" unchecked. Ta-da, this is how I did the paddle.
Here is a link to a unity package with an example.
https://dl.dropboxusercontent.com/u/6767980/PPRift/Example/Paddle_Follow.unitypackage
There is no guarantee that the knowledge given here is worth anything. Use at your own discretion. :lol:
Moving the Paddle with Head Tracking
The paddle follows your head movements on the X and Y axis, but remained Z locked.
This is quite easy actually. First, you need to create a child object in the "CameraLeft" in the OVRCameraController prefab provided by the Oculus VR Unity Integration. We will call this the "Follower Object". Place the Follower Object in front of the camera as far out as you need to give the object following it the full range it needs.
Now place the object you want to follow your movements into the scene (EX: a Paddle).
Apply the following script in C# to the Paddle object:
using UnityEngine;
using System.Collections;
public class FollowPosition : MonoBehaviour
{
public Transform followObject; //follow this object
public bool x; //enable or disable X axis
public bool y; //enable or disable Y axis
public bool z; //enable or disable Z axis
// Update is called once per frame
void Update ()
{
//Tells this object to follow the assigned game object
Vector3 newPosition;
newPosition.x = x ? followObject.position.x : transform.position.x;
newPosition.y = y ? followObject.position.y : transform.position.y;
newPosition.z = z ? followObject.position.z : transform.position.z;
transform.position = newPosition;
}
}
With the Paddle Object selected, click / drag the Follower Object into the "Follow Object" slot in the inspector. Now check "X" and "Y" but leave "Z" unchecked. Ta-da, this is how I did the paddle.
Here is a link to a unity package with an example.
https://dl.dropboxusercontent.com/u/6767980/PPRift/Example/Paddle_Follow.unitypackage
