- Home /
How do I shoot using buttons for ios
Hey, I'm still pretty new to unity game developing, I am currently making a game where you need to shoot upwards, the game is in 2D and I am going to use buttons since it will be an ios game and I want to make it shoot using a button. I want to know how to do it. This is my code so far.
{
public float speed = 50.0f;
private Rigidbody2D rb;
private Vector2 screenBounds;
// Start is called before the first frame update
void Start()
{
rb = this.GetComponent<Rigidbody2D>();
rb.velocity = Vector2.up * speed;
screenBounds = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, Camera.main.transform.position.z));
}
// Update is called once per frame
void Update()
{
if(transform.position.y < 0){
Destroy(this.gameObject);
}
}
}
Comment
Your answer
