Hockey Puck/ Soccer Ball physics

Hey All,
I am making a sports game and within it I have hockey and soccer. As of right now I am working on the hockey part. I have gotten my player to move around and dribble the puck (which is an animation) I was wondering if anyone knew how to make it so that when the shoot button is pressed the shoot animation occurs (i have the animation part done) and the puck goes straight and curves up into the air (floating up to be make it look realistic) in the direction that the player is facing. Any ideas?

Maybe AddForce in Y axis to make it float and let gravity pull it down along the way. I’m thinking of maybe getting the player’s quaternions to orient the puck before it leaps so it follows the direction of the player. Sorry I’m not a code junkie, just hoping to help a little. It would be my way of approaching the task.

You could use physX add Force and get a more or less nice result. I for myself was never satisfied with physX for flying balls and so had to dig into doing it by hand.

It involves coding the translation and make heavy use of physics formulas.

Some Keywords to step into:

trajectory parabola
magnus effect
kinetics

This is an aerodynamic effect and unfortunately all the action takes place in a vacuum in Unity, so you need to apply the force yourself. The lift force is proportional to the speed the puck is travelling and to the cosine of the angle between the flat side of the puck and the direction of travel. Surprising though it may seem, this is all neatly handled by the dot product of the puck’s velocity and its transform.up vector:-

var liftValue: float;  // Tweak this to get the right effect for the game.
  ...

var liftForce = liftValue * -Vector3.Dot(transform.up, rigidbody.velocity);
rigidbody.AddRelativeForce(Vector3.up * liftForce);

Thank you all for the help. I will try the lift force now and let you know how it all works.