How Calculate Rotation Y two objects?

i need calculate rotation Y of two objects
for make the player ball control

get Rotation Y of ray
get Rotation Y of Player
and calculate an rotation less other

somebody know something about it?

I’m not sure if i understood you correctly, but do you mean like football game?
So when the player is facing the ball something happens.

If im right, one way to do this is with Unity - Scripting API: Vector3.Angle

Example (with distance):

direction = transform.position - ball.position;
angle = Vector3.Angle(transform.forward, direction);
distance = direction.magnitude;
if (Mathf.Abs(angle) < 90 && distance < 1)
print("target is in front of me");