Unity RTS Tutorial - Camera Controller
ACCESS the FULL COURSE here: https://academy.zenva.com/product/strategy-game-development-academy/?zva_src=youtube-strategy-academy
TRANSCRIPT
Welcome back everyone. In this lesson we are gonna be working on our camera controller script, which is going to allow us to both move the camera left to right, forward and back as well as zooming in and out. So we can get a good view of our game scene and be able to navigate around. The camera is also gonna have the ability to focus on a certain position, so at the start of the game we're gonna be focusing on our unit spawn area so that the camera can easily show the player where our units are spawning, and later on, if you wanna implement stuff such as pressing a button to move to an idle unit, then this is also going to allow that. So first of all, we need to change our setup of our main camera right now, if we go on the scene view here you'll see that the main camera, it is just by itself, but what we need to do is we need to put this main camera inside of a container, and that is going to allow us to easily move around and figure out the center point down here, to figure out what is at the center of the camera, because if we don't, trying to center this camera on a certain point, we'll have to do some trigonometry, and yeah, it can get a bit confusing so we'll just keep it like this. So what we need to do is first of all, get our camera here, and we need to place it inside of an empty object. So I'm gonna create a new empty game object here, I'm gonna call it our camera, I'm gonna set it to zero, zero, zero, and now we just need to set the camera here, oh, drag this in as a child, and we need to set the main camera here to a position where we want the center of the map to be in the center of the screen. So I'm gonna set the y position here to 20, z to -17, and the rotation on the x axis to 50. So there we go, it looks like we're pretty much aiming in the center there, which is good. Field of view at 40, which is also good. And now what we can do is on our main camera object right here, let's create a new script inside of the scripts folder, and I'm gonna be calling this one our camera controller. We can then select our camera object that we just created here, and I'm gonna drag on the camera controller script, and now let's open it up inside of Visual Studio to begin scripting. Okay, here we are. First up, I'm just going to remove the start and update function just to get it a bit clean here when we enter in our variables, and first up for our variables, we need to know the move speed, this is going to be how fast are we gonna be moving the camera around with our arrow keys, then we also need to know a zoom speed, so how fast are we gonna be zooming in and out, so zoom speed here. And then, we also need to know what is the minimum distance we can zoom in, and the max distance we can zoom out, because we don't wanna be zooming through the terrain or really far out, so I'll go public float minZoomDist and another public float for the maxZoomDist. What else we need is going to be the camera, because when we are zooming the camera, we're gonna be moving it based on its forward direction yet when we're moving the camera, we're gonna be moving this parent object around. So here, I'll just go private camera cam, and there we go.
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Unity RTS Tutorial - Camera Controller», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.