So I am making a 2D game and every time I clicked on the screen space, my player would swims upward by a little bit. My next goal is to get my player to move left or right. So how do i make my player move right once i click on the right side of the screen space? I tried with …
target = Camera.main.ScreenToWorldPoint (Input.mousePosition);
it works ok but it’s not what i want. I don’t want my player to follow the mousePosition, i just want it to move right once the right side of the screen space is clicked. if i clicked left, it goes left.
I also tried …
if (target.x <= target.z)
{
transform.position = new Vector3( 5, 0, 0);
}
but that kind a transport my character to where i clicked.
Sorry, i didn’t upload the script. my entire script is too messy right now because I’ve tried many different method to get this to work but no luck.