This might seem straight forward but its more complex than the title explains.
This is a two player Asymmetric VR(HTC Vice) and PC game. The HTC is listed as the Main Camera looking around the world and the player on the PC using the monitor, mouse and keyboard needs to be clicking around the scene placing targets where an explosion prefab spawns killing the bad guys.
I am using Raycast to check the click of the mouse but I am having trouble telling it not to use the Main Camera which is default to the VR. I have separate Displays being called on start up but I’m not sure how to set the PC player screen to receive the raycast clicks because right now i think its going off the VR and my prefab is spawning all over in random spots.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CreateTargetLocation : MonoBehaviour
{
public GameObject prefab;
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Debug.Log("Left mouse clicked");
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit))
{
if (hit.transform.name == "floor")
{
Instantiate(prefab, hit.point, Quaternion.identity);
print("My object is clicked by mouse");
}
}
}
}
}