Hi guys,

I am new to Unity and trying to make a game to throw ball, I wrote the below code, but now I want the ball to hit the spot named "BallThrowPoint" and then go hit the target accordingly.

Code:


using UnityEngine;
using System.Collections;

public class Throwball2 : MonoBehaviour {
   GameObject prefab;

   void Start()
   {
      prefab = Resources.Load ("myball") as GameObject;
      }
   
   void  Update (){
      if (Input.GetMouseButtonDown (0)) {
         GameObject myball = Instantiate(prefab) as GameObject;
         myball.transform.position = transform.position + Camera.main.transform.forward * 2;
         Rigidbody rb = myball.GetComponent<Rigidbody>();
         rb.velocity = Camera.main.transform.forward * 40;

            }
         }
   
   }


Pls help,

Thanks in advance.