- Home /
Question by
$$anonymous$$ · Feb 24, 2020 at 11:47 AM ·
unity 5shootingswipe
Shoot only swipe
I have a code that works both tap and swiping. I want to make the code so that it can only shoot by swiping.
Vector3 mousePos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x,Input.mousePosition.y,5));
if(!IsPointerOverUIObject() && Input.GetMouseButton(0) && readyToshoot)
{
ball.GetComponent<Animator>().enabled = false;
ball.transform.position = new Vector3(mousePos.x,ball.transform.position.y,ball.transform.position.z);
}
Vector3 dir = target.position - ball.transform.position;
if ( Input.GetMouseButtonUp(0) && readyToshoot)
{
//StartCoroutine(BallSpawn());
ball.GetComponent<Rigidbody>().AddForce(dir * ballForce, ForceMode.Impulse);
readyToshoot = false;
}
Comment