Skip to content

Commit

Permalink
code formatting fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Prashant Singh committed Aug 19, 2019
1 parent 1f73a05 commit 355e4de
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ bounds.Initialize(GetComponent<Camera>()); will initialize the bounds script wit
And the maxXPos and maxYPos will be assigned with the bounds calculated values.

```csharp
void Update()
{
Vector3 currentPosition = transform.position;
Vector3 targetPos = new Vector3(Mathf.Clamp(player.position.x, maxXPos.x, maxXPos.y), Mathf.Clamp(player.position.y, maxYPos.x, maxYPos.y), currPos.z);
transform.position = Vector3.Lerp(currPos, targetPos, Time.deltaTime * speed);
}
void Update()
{
Vector3 currentPosition = transform.position;
Vector3 targetPos = new Vector3(Mathf.Clamp(player.position.x, maxXPos.x, maxXPos.y), Mathf.Clamp(player.position.y, maxYPos.x, maxYPos.y), currPos.z);
transform.position = Vector3.Lerp(currPos, targetPos, Time.deltaTime * speed);
}
```
Here we will clamp the x and y positions of our camera in the targetPos variable.
Which will prevent our camera to go past the maximum and minimum x and y positions.
Expand Down

0 comments on commit 355e4de

Please sign in to comment.