So I started writing some code for you. Then when I tested it, it didn't have the desired result. Here is the code so far. If anyone know what is wrong with it, do tell :-)
/// <summary> /// Adds the velocity to simulate throwing a ball /// </summary> /// <param name="angle">The angle of the throw along the z axis</param> /// <param name="direction">The degrees of the throw to the left or right</param> /// <param name="power">The power of the throw</param> private void ThrowBall(float angle, float direction, float power) { angle = Mathf.Max(Mathf.Min(0, angle), 90); //Make sure angle is between 0 and 90 direction = Mathf.Max(Mathf.Min(-45, direction), 45); //Make sure direction is between -45 and 45 power = Mathf.Max(1, power); //Make sure there is a power of at least 1 angle *= Mathf.Deg2Rad; //Convert angle to radians float xForce = Mathf.Cos(angle) * Mathf.Sin(direction); //Get the force to apply to the x axis to throw the ball to the left or right float yForce = Mathf.Sin(angle); //Get the force to apply to the y axis based on the angle float zForce = Mathf.Cos(angle) * Mathf.Cos(direction); //Get the force to apply to the z axis based on the angle Vector3 force = new Vector3(xForce, yForce, zForce).normalized; //Get the force in a Vector3 and normalize it so that the angle does not affect the power GetComponent<Rigidbody>().AddForce(force * power); //Get the Rigidbody Component and apply the force to it based on the angle and power }
It works if throwing in a straight line, but when adding a left/right directional force, it raises faster than it moves forward. I am very interested in finding an answer to this. I am going to keep looking, and I will update the code as I find out more information.
As for the trail, I would just add particles behind it.