Currently developing a little prototype RTS with the Oculus VR devkit. I want to implement camera movement via "grabbing" onto the world space with a touch controller and move the OVRCameraRig object on the X- and Z-axes. For the prototype purpose, I rather decided to go with a simpler approach, namely just pull the map around, since it's not that big, and not much is happening on it.
So far I got this script:
public class MapMover : MonoBehaviour
{
private bool movementEnabled;
Transform map;
Transform leftController;
Vector3 offset;
public bool IsMovementEnabled { get { return movementEnabled; } }
private void Awake()
{
leftController = GameObject.Find("LeftHandAnchor").transform;
}
public void BeginMovement()
{
offset = transform.position - leftController.position;
movementEnabled = true;
}
public void EndMovement()
{
movementEnabled = false;
}
private void LateUpdate()
{
if (movementEnabled)
{
transform.position = new Vector3(
(leftController.position.x * 1.1f + offset.x),
transform.position.y,
(leftController.position.z * 1.1f + offset.z)
);
}
}
}
BeginMovement()
is called when I press the Hand Trigger on the left Touch controller. My current results are unproductive: The first BeginMovement()
call is sufficient, but the movement of the map is very minimal, since the controller models are tiny and their position clamps around -1.0f
and 1.0f
. The second call of BeginMovement()
makes the map do a jump to either side before going back to the minimal movement.
My question is, what exactly am I missing? Is there a simpler approach to this?