Basketball going the wrong direction when moving a certain way

Hello everyone,

I’m working on a mobile game where the game mecanics is a simple basketball throw, the player movements are frozen in X and Z so he can only move on the Y axis. Player is animated using DOTween to make it bounce indefinetly and gameplay is basicaly touching the screen at the right time to throw the ball, all good so far.

To this player I parented a ball with a Rigidbody, and when input is detected, an instance of this ball is created and an AddForce(new Vector3(0, upthrust, thrust), ForceMode.Impulse) is added.

Here’s my issue :
When the player is in “falling” phase, the ball is thrown the right way, 0 on the X, upthrust on the Y and thrust on the Z.

Now when the player is on the “jumping” phasing, heading up, it looks like the ball fly in the opposite direction on the Y axis…

So I’m having trouble understanding what could cause this issue… I have a feeling that I’m missing something stupid :frowning:

Thanks for you help !

It might be that something about where you parented the ball is rotated in an unexpected way.

Start from the top and go down the hierarchy to where the ball is parented to the player. Every rotation going down should be (0,0,0), and if it is not that will be your problem.

The solution is to clean up your hierarchy to have zero rotation all the way down except for just the precise parts that might need it, such as the geometry itself.

Thank you for you help Kurt !
All my rotations where clear at 0,0,0 but I still tried to clean up my hierarchy, deleted and made the ball again from scratch, it’s now fixed !

I guess sometime that’s the best solution !

Thanks again

1 Like