I am making a football penalty kind of game. SO everytime ball goes out of the boundary i am respawning it to some random position. Now i want my camera to face the goal and the ball should also be in centre,
I am using transform.LookAt(goal.transform.position);
It is always facing the goal but the ball is randomly changing its position.
//Camera position
transform.position = new Vector3( ball.transform.position.x, ball.transform.position.y + 0.77f, ball.transform.position.z - 3f);
//Camera rotating towards goal
transform.LookAt(goalPost.transform.position );