So I am using an Oculus with the touch controllers and I am working on Teleportation for movement. I am basing my movement on the game robo recall. So I have a marker that is controlled by the a ray cast from the touch controller forward. So that is getting the marker in position, but I am having a hard time figuring out the rotation on the marker. This is just the last iteration, that doesn’t work.
RaycastHit hitting;
Marker.GetComponentInChildren<MeshRenderer>().enabled = true;
//Debug.DrawRay();
int layerMask = 1 << 8;
int markerMask = 1 << 8;
markerMask = ~markerMask;
int floorMask = LayerMask.GetMask("Floor");
if (Physics.Raycast(LHand.transform.position, LHand.transform.forward, out hitting, maxDistance, floorMask))
{
Marker.SetActive(true);
//Debug.Log("Point Found: " + hitting.point);
Vector3 dest = hitting.point;
Vector2 axis = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);
Vector3 direction = new Vector3(axis.x, 0, axis.y);
//Marker.transform.LookAt()
Quaternion rotation = Quaternion.LookRotation(direction, Vector3.up);
Marker.transform.rotation = rotation;
Marker.transform.position = dest;
}
else
{
Marker.GetComponentInChildren<MeshRenderer>().enabled = false;
}
So for those of you who have never played robo recall. Ill try and explain the functionallity. So the Marker is put on the ground when a player removes the joystick from center position. A ray would be drawn to see where it intersects with things the player can land on and the marker is drawn there. There is an arrow drawn off the local forward to show the direction the character will be facing when the teleport is complete. I want to adjust the rotation of the marker based off of the position of the Joystick. Pushing forward on the joystick should make the rotation of the marker equal to the direction of the player’s direction if it was looking at the marker.
From there I want to adjust the rotation based off of where the Joysticks Position. So for example if we are full to the left on the joystick (-90 degree) , then I want the marker to be set to ( direction of the player looking at the marker -90 degrees).
If there is another way to do it please let me know. I will take code help or just an explanation.