Script for passing and shooting a ball

Hi, I’m making a game where I need to pass and shot a ball/sphere. In my script the solution I made was the function transform.position, but the “teleport” effect wasn’t what I’m looking for. I need my ball go to a point to another moving with velocity and not teleporting. How I can do this? Any help? Thanks! I put here a small part of my script for any suggestions.

if(inTrigger){
    if( Input.GetKey(KeyCode.Joystick1Button1)){ 
    Soccer.transform.position = Pass.transform.position;

You can use a Vector3.Lerp

Change your if statement to this:

if ( inTrigger ) {
    if ( Input.GetKey( KeyCode.Joystick1Button1 ) && !isPassing ) {
        StartPass( Pass.transform.position );
    }
}

Make sure these variables are defined:

var isPassing : boolean = false;
var timeSoFar : float = 0;
var timeToPass : float = 3; // how long you want the pass to take.
var startPosition : Vector3 = Vector3.zero;
var finalPosition : Vector3 = Vector3.zero;

Place this function in your script:

function StartPass( finalPos : Vector3 ) {
    startPosition = Soccer.transform.position;
    finalPosition = finalPos;
    timeSoFar = 0;
    isPassing = true;
}

Place this in the Update function:

if ( isPassing ) {
    var percent = timeSoFar / timeToPass;
    Soccer.transform.position = Vector3.Lerp( startPosition, finalPosition, percent );
    timeSoFar += Time.deltaTime;
    if ( timeSoFar >= timeToPass ) {
        isPassing = false;
    }
}