Unity rts camera android

Unity rts camera android

RTS camera for Unity

Attach this script to a camera and then you can use it RTS-style.

Note: I’m a Unity newbie, so I’m sorry if I don’t know what I’m doing! Happy to accept pull requests.

Attach this script to a camera.

Add «Mouse Look» and «Mouse Select» to your inputs. I recommend changing the default Fire1 and Fire2 for left and right mouse buttons.

Make sure selectable objects have 3D colliders on them.

For any selectable object, add the following code:

For more usage, check out the demo.

One RTSCamera should be attached to the main camera for your game.

Property Type Default Description
disablePanning bool false When true, the player cannot pan the camera.
disableSelect bool false When true, the player cannot select.
disableZoom bool false When true, the player cannot zoom.
selectColor Color Color.green The selection box drawn on-screen will be this color.
selectLineWidth float 2f The selection box drawn on-screen will have this line width.
maximumZoom float 1f Maximum zoom; minimum camera scale. (This value will be less than minimumZoom , which might seem backwards.)
minimumZoom float 20f Minimum zoom; maximum camera scale. (This value will be greater than maximumZoom , which might seem backwards.)
lookDamper float 5f Panning speed will be divided by this value. A higher number makes for slower panning.
selectionObjectName string «RTS Selection» When a selection happens, a trigger (a BoxCollider) will be dropped briefly into the scene. It will have this name.

About

A little script for RTS games in Unity. Abandoned. Add an issue if you want to take over!

Источник

Unity rts camera android

A c# script to use as a component in your main camera to implement a RTS style or a fly through the world style camera. You can pan the camera either by keyboard or mouse both horizontally and vertically, as well as zoom in/out.

Читайте также:  Блокировка сенсора для андроид

You can either use the prefab that contains a camera with the script or attach the script to your main camera (add tag «main camera»). Once you have the script on your game object some options will be visible in the inspector.

The options in the script component are :

Screen border edge thickness : It describes how far from the edge of the screen the camera movement will be triggered. This field is only for the mouse movement option and can be easily changed by modifying the value.

Camera Mode : It defines the camera mode. The default is RTS Mode which sets camera to move based on the global coordinates. Other option is fly mode which sets camera to move based on the local coordinates of the camera game object.

Movement speeds : It defines the speed of the camera in the game. The speed starts from a minimum value and based on the secToMaxSpeed value it reaches to a maximum speed value.

Movement limits : It limits the camera’s movement on the 3D axes. You can define how far the camera can reach on each of z (length), x (width), y (height). Remember this tool works only if the boolean enableLimits is set to true. However, in case this option does not satisfy you, you can set it to false and add a rigid body as well as a collider to the camera and set gravity to false. Then insert empty colliders around your 3d world and the camera will collide with them, giving a movement limitation.

Rotation : Here you define if you want your camera to rotate and set the rotation speed. In RTS mode you can rotate the camera but when the mouse button is released the rotation returns to its default value. You can use the right mouse click to rotate the camera (click and hold).

About

A unity (c#) script that implements a RTS Camera for real-time strategy games.

Источник

Unity rts camera android

RTS camera for Unity

Attach this script to a camera and then you can use it RTS-style.

Note: I’m a Unity newbie, so I’m sorry if I don’t know what I’m doing! Happy to accept pull requests.

Attach this script to a camera.

Add «Mouse Look» and «Mouse Select» to your inputs. I recommend changing the default Fire1 and Fire2 for left and right mouse buttons.

Читайте также:  Window tablet or android tablet

Make sure selectable objects have 3D colliders on them.

For any selectable object, add the following code:

For more usage, check out the demo.

One RTSCamera should be attached to the main camera for your game.

Property Type Default Description
disablePanning bool false When true, the player cannot pan the camera.
disableSelect bool false When true, the player cannot select.
disableZoom bool false When true, the player cannot zoom.
selectColor Color Color.green The selection box drawn on-screen will be this color.
selectLineWidth float 2f The selection box drawn on-screen will have this line width.
maximumZoom float 1f Maximum zoom; minimum camera scale. (This value will be less than minimumZoom , which might seem backwards.)
minimumZoom float 20f Minimum zoom; maximum camera scale. (This value will be greater than maximumZoom , which might seem backwards.)
lookDamper float 5f Panning speed will be divided by this value. A higher number makes for slower panning.
selectionObjectName string «RTS Selection» When a selection happens, a trigger (a BoxCollider) will be dropped briefly into the scene. It will have this name.

About

A little script for RTS games in Unity. Abandoned. Add an issue if you want to take over!

Источник

Unity rts camera android

Acolit 12 июн 2012, 12:17

Re: Camera rotation android

DDDENISSS 12 июн 2012, 12:37

Re: Camera rotation android

Acolit 12 июн 2012, 13:35

Re: Camera rotation android

Acolit 14 июн 2012, 09:55

Re: Camera rotation android

Syberex 14 июн 2012, 09:58

Re: Camera rotation android

Acolit 14 июн 2012, 10:27

Re: Camera rotation android

Syberex 14 июн 2012, 10:33

Re: Camera rotation android

Acolit 14 июн 2012, 11:25

Re: Camera rotation android

Syberex 14 июн 2012, 11:39

Re: Camera rotation android

Acolit 14 июн 2012, 14:04

Re: Camera rotation android

Syberex 14 июн 2012, 21:53

Re: Camera rotation android

Acolit 14 июн 2012, 22:01

Re: Camera rotation android

Syberex 15 июн 2012, 15:20

Re: Camera rotation android

Acolit 15 июн 2012, 16:14

Re: Camera rotation android

Syberex 15 июн 2012, 20:45

Он не глючит, просто все не идеально, совершенство не достижимо и тд

Вот вам мой скрипт поворота камеры вокруг объекта:

using UnityEngine ;
using System.Collections ;

public class CameraTargetOrbit : MonoBehaviour <

public Transform target ;
public bool autoRotate = false ;

Читайте также:  Bad bobby saga для андроид

public float x = 0f ;
public float y = 2f ;
public float distance = 3f ;
public float distanceMin = 1f ;
public float distanceMax = 25f ;
public float offsetY = 0.5f ;

public float xSpeed = 0.1f ;
public float ySpeed = 0.25f ;

public float rotAngleX = 180f ;
public float rotAngleY = 180f ;

public float rotAngleYMin = 5f ;
public float rotAngleYMax = 45f ;

private Vector3 targetPos = Vector3. zero ;

public void Zoom ( float zoom )
<
if ( target && zoom != 0 )
<
distance += zoom ;
if ( distance distanceMin )
distance = distanceMin ;
if ( distance > distanceMax )
distance = distanceMax ;
>
>

public void Rotate ( float x1, float y1 )
<
x += x1 * xSpeed ;
y -= y1 * ySpeed ;
y = ClampAngle ( y, rotAngleYMin, rotAngleYMax ) ;
>

transform . position = target. position ;
//transform.rotation = Quaternion.Euler (target.transform.rotation.y + y, target.transform.rotation.x + x, 0);
transform . rotation = target. transform . rotation ;
transform . Rotate ( y, x, 0 ) ;
transform . position = transform . position — ( transform . forward * distance ) + ( transform . up * offsetY ) ;

targetPos = target. position ;
>
>

static float ClampAngle ( float angle, float min, float max )
<
if ( angle — 360 )
angle += 360 ;
if ( angle > 360 )
angle -= 360 ;
return Mathf. Clamp ( angle, min, max ) ;
>
>

У него надо вызывать метод Rotate(x1, y1) где x1 и y1 в градусах.
А Zoom (float zoom) это приближение отдаление камеры.

То есть добавить надо что-то типа:

либо вызывать методы Rotate и Zoom из отдельного скрипта, который отвечает за управление — так будет правильней.

Источник

Rotation камеры на Android

Фото с камеры (Android)
Не могу сделать фото, Осипов утверждает, что просто cameracomponent.Active:=true и после того как.

Беспроводная передача с веб камеры на Android
Добрый день! Занимаюсь программированием и электроникой уже почти 3 года и наконец-то появилась у.

Посоветуйте смартфон на Android с большой внутренней памятью и без камеры
Доброго времени суток. Посоветуйте телефон. Работаю на военном предприятии и в связи с этим у.

Transform.rotation
Для стратегии камера должна не только передвигаться, но и менять угол просмотра. Для этого, при.

причем здесь вращение камеры? О_о
Всё можно сделать проще же. Впрочем, напишу с утра уже.

Добавлено через 9 часов 46 минут

C# freeze rotation
C# под unity3D. Нужно через скрипт отклбчить freeze rotation Z

Можно ли заморозить rotation x и y ?
Когда объекта начинает двигаться за курсором у него начинает меняться значение поворота по x и y на.

Transform.rotation. Углы
У меня есть камера, rotation(90,0,0). Необходимо повернуть её по Z при нажатии стрелки влево, но.

Child component rotation over network
Добрый день! У меня возникли сложности в создание небольшой сетевой игры в Unity 3D. Суть игры в.

Источник

Оцените статью