0
votes

Here is an image of what I'm trying to achieve Game screen of the game i'm Writing

As you can tell it's a split screen game, the player is on the left, computer on the right. there are 3 cameras in the game, main and two player cameras

the player camera MUST be independent of the player and CAN NOT be a child object of the player object, because the ball bounces and rotates while moving, the cameras must not. when the balls change direction the camera must remain behind the player so the visual appears to show the landscape rotating with the player. I've searched high and low for anything to put me on the right path but nothing seems to work right. It should be a smooth transition so lerp and slerp are to slow for instant moving. I know LateUpdate will help with this. If anyone can point me in the right direction I'd appreciate it.

Many thanks, Paul

1

1 Answers

0
votes

Have a script which takes in an object's position, in this case the player's ball, so you can code the camera as if it was a child of the object.

An simple example code for having a following camera would be something like...

FollowObject.cs

public Transform exampleObject;
private int offset = 5; //How far back the camera will be

void LateUpdate()
{
    transform.position = new Vector3(exampleObject.transform.position.x,
                                     exampleObject.transform.position.y, 
                                     exampleObject.transform.position.z - offset)
}