- Home /
mouse input and touch input giving different results
Hi guys. So I am testing my game both on pc and android but i have come across an annoying problem. my Input.GetMouseButton(0) and Input.GetTouch(0) bools all calculate my player speed by 150f * Time.deltaTime (on both halves of the screen) in my FixedUpdate method. The problem is, when using the touch input, the player speed is 5 times faster than when i use my mouseInput. what could be the problem? Please help
if(Input.GetMouseButton(0)){
Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition));
var click = Camera.main.ScreenPointToRay(Input.mousePosition);
Vector3 mousePos = Input.mousePosition;
if(mousePos.x < Screen.width/2){
transform.Rotate(0,0,rotateSpeed * Time.deltaTime);
Debug.Log(" left ");
}
else if(mousePos.x > Screen.width/2){
transform.Rotate(0,0,-rotateSpeed * Time.deltaTime);
Debug.Log(" left ");
}
}
if(Input.touchCount > 0){
var touch = Input.GetTouch(0);
if(touch.position.x < Screen.width/2){
transform.Rotate(0,0,rotateSpeed * Time.deltaTime);
Debug.Log("Left Click");
}
else if(touch.position.x > Screen.width/2){
transform.Rotate(0,0,-rotateSpeed * Time.deltaTime);
Debug.Log("Right Click");
}
}
Answer by Henry693 · May 14 at 11:56 AM
Import in the CrossPlatformInput package into your project and you could actually continue to use Input.GetMouseButton(xxx). myloweslife
Will try that out...I had managed to fix the problem by using a bool which then accepts the input based on which platform i am on...like a public bool pc, mobile; & separated the inputs under if (pc) and if (mobile)...works like a charm, somehow