Shooting a rigidbody from on arbitrary point to another arbitrary point in a 3D space is the basis of my question. I’m attempting to make a crowd throw objects towards either player one or player two but I’m struggling to get the maths to send it in the correct direction.
My current attempt:
[ContextMenu("Do ThrowTomatoes")]
public void ThrowTomatoes()
{
GameObject clone;
GameObject tomatoe = GameObject.FindGameObjectsWithTag("Throwable")[0];
clone = (GameObject)Instantiate(tomatoe, new Vector3(tomatoe.transform.position.x, tomatoe.transform.position.y, tomatoe.transform.position.z), Quaternion.Euler(0, 0, 0), CameraMovement.playerOne.transform);
clone.AddComponent<Rigidbody>();
Debug.Log(CameraMovement.playerOne.transform.position.x +" "+ CameraMovement.playerOne.transform.position.y + " " + CameraMovement.playerOne.transform.position.z);
clone.GetComponent<Rigidbody>().velocity = new Vector3(1, 1, UnityEngine.Random.Range(5, 20));
}