- Home /
How do I make the camera zoom out, relative to my players size?
I have been trying to make a game similar to Agar.io that uses some similar mechanics. However, when I become too large in the game my player becomes larger than the camera view actually is. I need a camera script that will allow me to do this without interfering with my other camera script.
This is my Growth script.
This is my Camera script.
Answer by xxmariofer · Jan 23, 2019 at 02:41 PM
Cretae a float value called something like incrementCameraValue and increase in the ontriggerenter method using the Camera.main.orthographicSize += incrementCameraValue; You can save the camera in a var for better performance too.
Answer by GhostOfTheJoker · Jan 23, 2019 at 03:09 PM
Thank you, found that this worked perfectly but instead I used the Increase from my growth script to replace the incrementCameraValue; . Do you know a way of making the camera smooth instead of jittery? @xxmariofer
well, you can just create a coroutine for doing that
IEnumerator IncrementOrtograficSize() { int iterator = 0; int numberOfClicles = 10; float amount = incrementCameraValue / numberOfClicles;
while (iterator < numberOfClicles)
{
iterator++;
yield return new WaitForEndOfFrame();
}
}
if you increment the numberOfCicles value it will do it more smoothly, just call that coroutine from there using StartCoroutine
Your answer
![](https://koobas.hobune.stream/wayback/20220612190320im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Camera following player in Tutorial Demo (Roll A Ball) 0 Answers
Networked Game Issues - Camera does not follow script 1 Answer
C# - Offset In-Air Camera from Current Object Position 1 Answer
Multiplayer Game Player Camera not Working 2 Answers
Player goes in other direction when moving mouse a long time 0 Answers