Flying Camera View Unity Project
Here is the code i used :
public static CameraController instance;
public float normalSpeed;
public float fastSpeed;
public float movementSpeed;
public float movementTime;
public Vector3 newPosition;
//CameraFollowObjectOnClick
public Transform followTransform;
//ZoomSettings
public Transform cameraTransform;
public Vector3 zoomAmount;
public Vector3 newZoom;
//mouseSettings
public Vector3 dragStartPosition;
public Vector3 dragCurrentPosition;
public Vector3 rotateStartPosition;
public Vector3 rotateCurrentPosition;
//RotationSettings
public float rotationAmount;
public Quaternion newRotation;
// Start is called before the first frame update
void Start()
{
instance = this;
newRotation = transform.rotation;
newPosition = transform.position;
newZoom = cameraTransform.localPosition;
}
// Update is called once per frame
void Update()
{
if(followTransform != null)
{
transform.position = followTransform.position;
}
else
{
HandleMouseInput();
HandleMovementInput();
}
if(Input.GetKeyDown(KeyCode.Escape))
{
followTransform = null;
}
}
void HandleMouseInput()
{
//ZoomMouse
if(Input.mouseScrollDelta.y !=0)
{
newZoom += Input.mouseScrollDelta.y * zoomAmount;
}
//MoveMouse
if(Input.GetMouseButtonDown(0))
{
Plane plane = new Plane(Vector3.up, Vector3.zero);
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
float entry;
if(plane.Raycast(ray, out entry))
{
dragStartPosition = ray.GetPoint(entry);
}
}
if (Input.GetMouseButton(0))
{
Plane plane = new Plane(Vector3.up, Vector3.zero);
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
float entry;
if (plane.Raycast(ray, out entry))
{
dragCurrentPosition = ray.GetPoint(entry);
newPosition = transform.position + dragStartPosition - dragCurrentPosition;
}
}
//RotationMouse
if(Input.GetMouseButtonDown(2))
{
rotateStartPosition = Input.mousePosition;
}
if (Input.GetMouseButton(2))
{
rotateCurrentPosition = Input.mousePosition;
Vector3 difference = rotateStartPosition - rotateCurrentPosition;
rotateStartPosition = rotateCurrentPosition;
newRotation *= Quaternion.Euler(Vector3.up * (-difference.x / 5f));
}
}
void HandleMovementInput()
{
if(Input.GetKey(KeyCode.M))
{
movementSpeed = fastSpeed;
}
else
{
movementSpeed = normalSpeed;
}
//GoUp
if(Input.GetKey(KeyCode.Z) || Input.GetKey(KeyCode.UpArrow))
{
newPosition += (transform.forward * movementSpeed);
}
//GoDown
if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow))
{
newPosition += (transform.forward * -movementSpeed);
}
//GoLeft
if (Input.GetKey(KeyCode.Q) || Input.GetKey(KeyCode.LeftArrow))
{
newPosition += (transform.right * -movementSpeed);
}
//GoRight
if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
{
newPosition += (transform.right * movementSpeed);
}
//RotationKey
if (Input.GetKey(KeyCode.E))
{
newRotation *= Quaternion.Euler(Vector3.up * rotationAmount);
}
if (Input.GetKey(KeyCode.A))
{
newRotation *= Quaternion.Euler(Vector3.up * -rotationAmount);
}
//ZoomKey
if (Input.GetKey(KeyCode.R))
{
newZoom += zoomAmount;
}
if (Input.GetKey(KeyCode.F))
{
newZoom -= zoomAmount;
}
//GetSmouthMovement
transform.position = Vector3.Lerp(transform.position, newPosition, Time.deltaTime * movementTime);
transform.rotation = Quaternion.Lerp(transform.rotation, newRotation, Time.deltaTime * movementTime);
cameraTransform.localPosition = Vector3.Lerp(cameraTransform.localPosition, newZoom, Time.deltaTime * movementTime);
}
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Flying Camera View Unity Project», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.