using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PickUpObject : MonoBehaviour
{
GameObject prefab;
public GameObject prefab2;
public bool ballThrown = false;
void Start()
{
prefab = Resources.Load("projectile") as GameObject;
}
void Update()
{
if(Input.GetMouseButtonDown(0))
{
if (ballThrown == false)
{
GameObject projectile = Instantiate(prefab) as GameObject;
projectile.transform.position = transform.position + Camera.main.transform.forward * 2;
Rigidbody rb = projectile.GetComponent<Rigidbody>();
rb.velocity = Camera.main.transform.forward * 40;
ballThrown = true;
}
if(ballThrown == true)
{
}
}
}
void OnCollisionStay(Collision node)
{
if (node.gameObject.tag == "ball")
{
ballThrown = false;
Destroy(node.gameObject);
}
}
}