how to shoot the ball in the direction of the arrow ?

hi guys, please i want to know how to shoot the ball according to the arrow direction , the arrow ping pong in the z axis between 3 and -3

here is an image that illustrates the game please i need your help!

@Eric5h5 @tanoshimi @Bunny83 @robertbu @clunk47

Hello.

Firt learn, find, how to know the rotation of the arrow.

Then just apply a force, a velocity or translate the ball in the same rotation vector direction.

If the ball is in a GameObject (which it has to be) then use the forward value.

Ball.transform.forward.

here’s some pseudo code to get you started:

public float forceAmount=5f; // Change this amount to increase/decrease the speed and distance the ball goes.

void Start(){
// Get the rigid body - this should be done in the Start()
Rigidbody rb = GetComponent<Rigidbody>();
}

void Update(){
if (Input.GetKey(kecode.Space)) ShootBall();
}

// Shoot the ball in the direction facing
void ShootBall(){
rb.addForce(transform.forward, forceAmount);
}

I just roughed this out, but it should get you started. Good luck!