using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GameController : MonoBehaviour
{
int score = 0;
int force = 1000;
// Move balloons
void Update()
{
//Calls bounce method each time button is clicked on a balloon
if (Input.GetMouseButtonDown(0))
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit) && hit.transform.CompareTag("Balloon"))
{
Debug.Log("Touched a balloon");
//hit.rigidbody.AddForce(ray.direction * hitForce);
}
}
/*if tapped on a balloon, bounces it
if ((Input.touchCount > 0) && (Input.GetTouch(0).phase == TouchPhase.Began))
{
Debug.Log("Touched screen");
Ray raycast = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
RaycastHit raycastHit;
if (Physics.Raycast(raycast, out raycastHit))
{
if(raycastHit.collider != null)
{
Debug.Log("Touched a balloon");
score = +1;
/*Rigidbody bl;
bl = raycastHit.rigidbody;
score++;
bl.AddForce(0, force, 0);
}
}
}*/
}
}