- Home /
endless runner game help
I have made an endless runner game for PC. I am trying make it so if you touch the left hand side you will jump and if you touch the Right hand side you will shoot. I have got an idea how to do that but I don't know how to do that. E.g. if the mouse has been clicked and it is less than 5 on the x axis then it should the player should jump or if it is more than 5 on the x axis then it should shoot. THANKS IN ADVANCED. I know this question is a little hard to understand but please help, that would be great. THANKS IN ADVANCED!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$$anonymous$$ay I ask your level of program$$anonymous$$g? I notice youve been at this for some time now. I'm curious to know what it is you are struggling with.
I admire your persistence.
Answer by NickP_2 · May 29, 2014 at 11:57 AM
Just device the screen size in 2, for example:
if(Input.MousePosition.x < Screen.Width / 2)
{
//left
}
else
{
//right
}
I was going to put my game on to the android app store so I will put your name on it for helping
Answer by konashadow · May 29, 2014 at 12:02 PM
If I understood this correctly, you want to get whether the tap occurs on the left or the right and run different code depending on which one it is. You can use Input.mousePosition to get the mouse's position on the screen, then just read the x value of that. In case my explanation didn't make sense, here's an example:
//C#
void Update () {
if(Input.GetMouseButtonDown(0)) {
Vector2 pos = Input.mousePosition;
if(pos.x < 100) {
Debug.Log("Jump");
} else if(pos.x > Screen.width - 100) {
Debug.Log ("Shoot");
}
}
}
Hope this helps!
I was going to put my game on to the android app store so I will put your name on it for helping
Your answer
![](https://koobas.hobune.stream/wayback/20220613150149im_/https://answers.unity.com/themes/thub/images/avi.jpg)