How to develope RTS Map ?
how to make map like clash of clan ? I want to zoom in and out and with drag . Also the map should not cross the area. Thank you
Answer by ijidau · Nov 11, 2015 at 01:03 AM
Your question is too vague/broad to answer. Please read the FAQ
You should break the problem down into pieces, search for tutorials on the individual aspects, then maybe consider asking questions specific to each aspect here on Unity Answers if you cannot find the right information.
To get you on track to finding what you need: CoC uses a tile-based map, which you view from an isometric camera. Touch input like dragging then alters the zoom of this camera. You should search tutorials for 'tile-based' maps, 'isometric' cameras and 'touch input'.
Answer by NvGBoink · Nov 10, 2015 at 08:45 PM
So here is a starting point for you ... public float camSpeed = 5; public float camScrollSpeed = 3; public float smoothing = 3; private Vector3 cameraStart;
void Start ()
{
//Get the position of the camera.
cameraStart = this.transform.position;
//Set the camera to look down at the map.
this.transform.eulerAngles = new Vector3 (90,0,0);
}
void Update ()
{
//Get the input as a float.
float horizontal = Input.GetAxis ("Horizontal") * camSpeed;
float vertical = Input.GetAxis ("Vertical") * camSpeed;
float height = Input.GetAxis ("Mouse ScrollWheel") * camScrollSpeed;
//Make a Vector using the 3 input floats.
Vector3 newPosition = this.transform.position += new Vector3 (horizontal, -height, vertical);
//Smoothly move the camera.
this.transform.position = Vector3.Lerp (transform.position,newPosition , Time.deltaTime * smoothing);
}
paste this into a c# script and attach it to your camera. This will make a camera controlled by your wasd or arrow keys. It will also zoom in and out based on your scroll wheel input.
For the other part I'm going to leave that to you :) First you will need to use a if statement to check the position of the camera and if it is leaving your defined area. I recommend using a distance from the centre of your map to do this.
float distance = Vector3.distance(this.transform.position, Vector3.zero);
The example above will make a float called distance that will represent the distances from the centre of the game world. You could then use ...
if(distance >= 100)
{
//Some how stop movement.
}
Also you may want to use a raycast to fire down and check how far the camera is from the ground and add stop the scrolling if it gets too close.
Your answer
Follow this Question
Related Questions
Movement and zoom of camera on the map 0 Answers
Change Camera's size relative to player's speed 0 Answers
Touch to move and drag to rotate object 2 Answers
moving an object on the y and x axis to mouse location 0 Answers
Objects being dragged 1 Answer