Reputation: 73
I have a gameobject that is moving in angular path like the image
But the camera is not following the player. If I am setting the Y value of the camera equals to the Y value of the player and keeping the x and z constant (0 & -10 respectively). It is showing me straight x movement of the player only (just like the image)
I guess the reason is the same Y value of both camera and player.
I am not sure how to make the camera follow the player that shows the exact movement I have in image 1.
Any help on this will be appreciable.
P.S. - please excuse my drawing skills, I know they are pathetic.....
Upvotes: 0
Views: 193
Reputation: 4343
If you want the camera to follow the player, there is no way to exactly show the movement you have above, since the ball would have to move off the screen. Since the camera position is relative to the ballposition, it will always appear as though the ball is moving horizontally as long as the camera moves at the same y-speed of the ball.
You will have to give the ball some appearance of movement, either by adding texture to the wall, a trail to the ball, a static background, or you could add something like lag to the camera (which will only work if the ball varies in speed):
Camera.main.transform.position = Vector3.Lerp(Camera.main.transform.position, ball.transform.position, .2f); // change .2f for different time lag
Upvotes: 3