I have a gameobject (sphere) which can be thrown using the left mouse button. It gets thrown in the rotation I look at (the sphere is a child of the head of the player, so that it moves with him). The problem is, if I throw the sphere while moving, it lands behind the player, because the moving speed of the player is not added to it.
I move my player like this:
float forward = Input.GetAxis("Vertical");
float right = Input.GetAxis("Horizontal");
transform.Translate(Vector3.forward * forward * forwardSpeed * Time.deltaTime +
Vector3.right * right * rightSpeed * Time.deltaTime);
I tried this with applying force to a rigidbody, but then the character is gliding over the ground (and the result was still the same).
I throw the ball like this:
body.useGravity = true;
body.isKinematic = false;
body.AddForce(transform.forward * throwForce, ForceMode.Impulse);
The Hierarchy is like follows: Player → Head → Thrower → Ball
So how can I do a physically “correct” throw?