Hi everyone!
I'm trying to get the player to throw the ball. I tied the ball using joints.
I have already tried with pinjoint and with conetwistjoint.
The moment the player presses the throw key, a scene instance is created as in the screenshot above.
My camera was made using two objects. One is responsible for the horizontal axis, and the second for the vertical.
((PlayerCamera)_sm.PlayerCamera).CameraH.GlobalTransform.basis.z;
This is how I get the direction of where to throw the ball. This is the horizontal camera forward vector.
Ball.ApplyCentralImpulse(forwardVector * force);
Then I apply an impulse to the ball using a forward vector * force (force = 20).
Perhaps I'm somehow applying impulse incorrectly? But it seems to me that physics somehow does not work that way. Because if you throw the ball exactly along the Z-axis or along the X-axis, then it flies correctly, but if you do it in between, then physics for some reason breaks...
Here's how it works on video: https://imgur.com/tzjcoIe