Unity Game Small Map generation

Source: Internet
Author: User

Sun Guangdong 2015.6.25

Step-by-step implementation of this feature:

Step 1:

Select "Gameobject"-"Create Other"-"camera" in the menu bar to create a new camera that will act as a dedicated camera for the small map, adjust his position so that it is vertically down above the scene, and then set it to orthographic. Remove the pivot and resize the size, change the view size, set the viewport Rect to change the location and size of the camera display area:



Step 2:

Run the game, there will be a small map at the top right of the screen, but you can not see the contents of the inside, may not be the correct location.

Now the small map camera and the normal camera display is the same, but it is viewed from the top down. Next, what we want to do is make the small map camera focus only on what it needs, and script to make the view of the small map camera always a square at any resolution.


Step 3:

Create a sphere, named dummy, and set its material to red self-illumin/diffuse, which will be the enemy's "replacement" only shown in the small map, and cannot be displayed in the main camera view. Remove the sphere sphere Collider. We only need its display function.


Step 4:

Create a layer, name dummy, and set the layer bit dummy of the sphere.


Step 5:

Place the sphere under the enemy's prefab level so that it moves as the enemy moves:


Step 6:

Select the main camera, suppress the dummy layer, and the sphere will not be displayed in the main camera view:



Step 7:

Select the small map camera so that it shows only the level and dummy layers so that only scenes and spheres can be seen in the small map.



Step 8:

Use the same method to create a "substitute" for the protagonist, you can make a different color for the enemy.


Step 9:

Create a script MiniCamera.cs, assign it to a small map camera, and add the following code:

Using unityengine;using System.Collections;  [Addcomponentmenu ("Game/minicamera")]public class Minicamera:monobehaviour {//Use the For Initializationvoid Start () {        //Get screen resolution ratio        float ratio = (float) screen.width/(float) screen.height;        The camera view is always in a positive direction, the first two parameters of the rect represent the XY position, and the latter two are XY size this        . Getcomponent<camera> (). Rect = new Rect ((1-0.2f), (1-0.2f * ratio), 0.2f, 0.2f * ratio);}}

The code here is very brief, mainly to make the view of the small map camera always a square.


Step 10:

Because there is already a audiolistener on the main camera, only one of the components is allowed in the same scene, so uncheck (or delete) the "Audiolistener" of the small map camera.

OK is complete.


If you want to continue to improve the display of small maps, you can also create a model for the scene to display for small maps.




????

Unity Game Small Map generation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.