Physics Help (423522)

Hey guys I am new to the physics/add force/add velocity thing. Anyway I am doing my pong game to exercise on these stuff. If anyone could guide me on this:

function Update () 
{


}

function OnTriggerEnter(collisionInfo : Collider)
{
if(collisionInfo.gameObject.tag == "player1")
{
transform.position.x = 1130.362;
rigidbody.velocity = Vector3.left * 4000;
}

if(collisionInfo.gameObject.tag == "player2")
{
transform.position.x = -1130.362;
rigidbody.velocity = Vector3.right * 4000;

}


}

right now when the ball hits the player it moves left and right only. Could anyone like teach me how to give it a force according to where the player hits. For example if the player hits the ball from down it goes down and stuff! if you could give me any tutorial or anything that might help me! Thank you a lot!

If my memory is good, there is a part in the FPS Tutorial that shows you how to apply a force to a rigidbody’s part, when you shoot at it.

http://unity3d.com/support/resources/tutorials/fpstutorial

You could have a quick look ? :wink:

hey that didnt help me a lot :s but thanks anyway!

sorry but could anyone tell the way to go thanks!

Find the vertical distance between the ball and the paddle (how far along the paddle the hit occurred), and add that in to your new velocity.

dist = Vector3.Distance(other.position, transform.position);

you mean like this right? the other being player1 and transform.position is the ball!
and then I add :
rigidbody.velocity =dist+ ( Vector3.left * 4000);

like this? thanks for your help!!

I just need a little more help with this sorry for nagging but i have been trying to fix it and its not working!