Hi
I want to have two players, at the same time, each moving their own cursor (maybe one with a joystick, or the keyboard). Preferably with both having the functionality one finds on the mouse cursor in Unity.
How can I do this?
thanks.
Hi
I want to have two players, at the same time, each moving their own cursor (maybe one with a joystick, or the keyboard). Preferably with both having the functionality one finds on the mouse cursor in Unity.
How can I do this?
thanks.
I figured as much, so I went ahead an did this (in case someone is interested):
public Texture customImageP2;
public float cursorSpeedP2 = 100.0f;
//Coordinates of Player´s 2 mouse. (starts center of screen)
private Vector3 mousePosP2 = new Vector3(Screen.width/2,Screen.height/2,0);
void OnGUI(){
//Player 2
//Move cursor
if (Input.GetKey(KeyCode.A)) //<--
mousePosP2 += new Vector3(-1 * cursorSpeedP2 * Time.deltaTime,0 ,0);
if (Input.GetKey(KeyCode.D)) //-->
mousePosP2 += new Vector3(1 * cursorSpeedP2 * Time.deltaTime, 0,0);
if (Input.GetKey(KeyCode.W)) //Up
mousePosP2 += new Vector3(0, 1 * cursorSpeedP2 * Time.deltaTime, 0);
if (Input.GetKey(KeyCode.S)) //Down
mousePosP2 += new Vector3(0, -1 * cursorSpeedP2 * Time.deltaTime, 0);
//Implement "clicking".
if (Input.GetKey(KeyCode.Q)) //RMC
{
//send fire 1 to under the mousePosP2
}
if (Input.GetKey(KeyCode.E)) //LMC
{
//send fire 2 to under the mousePosP2
}
//Draw the second Cursor
Rect posP2 = new Rect(mousePosP2.x, Screen.height - mousePosP2.y,
customImageP2.width,customImageP2.height);
GUI.Label(posP2,customImageP2);
}
So far I´ve yet to figure out how to implement the Player 2 right and left mouse clicks, so they behave as the real mouse clicks (or a way to fake/send a Input.GetMouseButtonUp(0) when the player presses “Q”)