assign velocity problem

I want to show the effect of banana kick towards a specific point.I use Vector3.RotateTowards routine to gradually change the direction of ball from its current velocity to the target. Since I don’t need to process the y axis velocity, I only change the other two. Then when everything is OK, I assign a new Vector to rigidbody.velocity while the y speed is unchanged. Here is the problem.
When I used the assign statement, the spot the ball hits is different from when I did not use statement. In fact, it is more far away than before. I was very confused. My core code are listed below.

velocityWithoutY=Vector3.RotateTowards(rigidbody.velocity,rivalPos,speed*Time.deltaTime,0f);

velocityWithoutY.y=rigidbody.velocity.y;

rigidbody.velocity=velocityWithoutY;

This is in the update(){}
Can anyone help me. I really can not figure what is going on here.

Think maybe two different things:

Is rivalPos the world-position of the ball’s target? If so, should probably convert it into “direction to target,” which would be something like rivalPos-ballPos;

Think of it this way: velocity is a direction: if your speed is (0,0,4), it doesn’t mean you’re along the left edge of the field. It means you’re going North. So math with velocity should be done using another direction.

Also, rotateTowards shouldn’t angle up or down, or you loose speed: if it cocks up a little, x and z get smaller. That’s normally fine, since y gets bigger and total 3D speed is constant. But not with you replacing y. Standard flat trick is to make the target count as having the same y as you: Vector3 levelRP = rivalPos; levelRP.y=myY; [do math using levelRP]