I want to ask about the Mouse Input.
I made 2 target point : control by mouse position and arrow key. Target1 will shoot when Left click, and target2 will shoot when right click.
Here is my code :
ray0 = Camera.main.ScreenPointToRay (Input.mousePosition);
ray1 = Camera.main.ScreenPointToRay (new Vector2 (target2.transform.position.x * Screen.width,target2.transform.position.y * Screen.height));
target1.transform.position.x = Input.mousePosition.x/Screen.width;
target1.transform.position.y = Input.mousePosition.y/Screen.height;
translation : float = Input.GetAxis (“Vertical”) * target2SpeedextraSpeed;
translation2 : float = Input.GetAxis (“Horizontal”) * target2SpeedextraSpeed;
target2.transform.Translate (0, translation*Time.deltaTime, 0);// Move translation along the object’s y-axis
target2.transform.Translate (translation2*Time.deltaTime, 0, 0);
if (plane.Raycast(ray0,dist0))
{
if (Input.GetMouseButtonDown(0))
{
var hitPoint0=ray0.GetPoint(dist0);
bulletMcopyL.GetComponent(bulletM_setting).targetP= hitPoint0; // script of direction bullet shooting
}
}
if (plane.Raycast(ray1,dist1))
{
if (Input.GetMouseButtonDown(1))
{
var hitPoint1=ray0.GetPoint(dist1);
bulletMcopyR.GetComponent(bulletM_setting).targetP= hitPoint1; // script of direction bullet shooting
}
}
My problem is : it’s not working right when I click left and right mouse in the same time. The direction of target1 is same with direction of target2.
. How can I solve this problem ?
My code is right when just left click or right click.
Thank you for you help. ![]()
P/S : Sorry about my English.