Unity3d Learning Tutorial C # Script control camera

Source: Internet
Author: User

Create a new script first

Click Create a folder named C #

Click the folder to create a C # script

Double-click File after building the file

Start the Script Editor

void Start () is the scene runtime loader

void Update () is a program that is executed every time a call to a needle is considered to be a trial execution

Write the first script below

Control camera Movement

Using Unityengine;

Using System.Collections;

public class Acc:monobehaviour

{

int speed=50;

void Start ()

{

}

void Update ()

{

float x = Input.getaxis ("horizontal") * Time.deltatime * speed;//move around

float z = input.getaxis ("Vertical") * Time.deltatime * speed;//move forward and backward

Main Camera Object Movement

Transform. Translate (X,0,Z);

}

}

Input.getaxis is the input manager

Click Edit

Understanding the input Manager

The red part is the key information

Horizontal is moved in parallel by pressing a D key and <----> arrow keys to Pan

Calling code

Input.getaxis ("Horizontal")

Time.deltatime is the time interval

Speed = 50; Is the step size

Distance to move around

float x = Input.getaxis ("horizontal") * Time.deltatime * speed;//move around

float z = input.getaxis ("Vertical") * Time.deltatime * speed;//move forward and backward

Main Camera Object Movement

Transform. Translate (X,0,z)

Unity3d Camera Detailed
Just as the footage in the movie is used to present the story to the audience, Unity's camera is used to present the game world to the player. You always have at least one camera in the scene and you can also have multiple. Multiple cameras can give you a two-person split-screen effect or create an advanced custom effect. You can let the camera move or control them with physical (components). Almost anything you can think of can be made possible with a camera, and in order to fit your game style, you can use a typical or special camera type.
Camera
A camera is a device that captures and displays the world for players. By customizing and manipulating the camera, you can make your game look different. In one scene you can have an unlimited number of cameras. They can be set to render in any order, render anywhere on the screen, or simply render part of the screen.

sf_2711512_2492.jpg (58.03 KB, download count: 917)

Download attachments to albums

2012-6-3 19:24 Upload


Property
· Clear flags clears the mark to determine which part of the screen will be cleared. When using multiple cameras to depict different game scenes, it is very convenient to use it


· Background background The selected color is applied to the remaining screen when all the elements in the lens are depicted and no sky boxes are in place


· The culling mask culling mask contains or ignores the camera render object layer. Assigning layers to your objects in the Inspector View


· Projection projection Switching camera's analog perspective function


The--> perspective perspective camera will render the object in a fully pivoted manner.


--> orthographic orthographic camera renders objects evenly in a way that does not have a sense of perspective


· Size sizes The viewport size of the camera when orthogonal is set.


· field of view range camera's angle of view width, and longitudinal angle dimensions.


· Clipping the distance between the Planes clipping plane from the camera to the start and stop rendering.


--> near the nearest point of the camera is depicted relative to the closest point.


--> far point began to depict the farthest point relative to the camera.


• Normalized viewport rectangles use four values to indicate where the camera's view will be drawn on the screen, using a screen coordinate system (value 0-1).


--> X camera View will be drawn at the starting point of the horizontal position


--> Y Camera View will draw the starting point of the vertical position


--> W (width) Width camera output to the width of the screen


--> H (height) height


• The height of the camera output to the screen


· Depth the camera position in the depth drawing order, a camera with a larger value will be drawn on top of the camera with a smaller value


· Rendering path render paths This option defines the rendering method that the camera will use


--> use player Settings to set the camera to use the render path set in any player settings


--> Vertex lit vertex illumination This camera renders all objects as vertex light objects


--> Forward Fast rendering all objects will be rendered as one channel per material, as in unity2.x standard


--> Deferred Lighting delay illumination all objects will be illuminated once, and then the illumination of all objects will be rendered together at the end of the render queue


· Target Texture Destination Texture (Unity pro/advanced only) refer to the render Texture, which contains the output of the camera view. This reference property disables the ability of the camera to render to the screen.
Details


The camera is essential for displaying your game to the player. They can be customized, scripted, or quilt-like to achieve almost any conceivable effect. For a puzzle game, you want to keep the camera in a static display full view. For a first-person shooter, you should use the camera as a sub-object of the player's character and place it at a high level with the character's eyes. For a racing game, you might prefer to have the camera follow the player's vehicle.

520 520 novel novel 520 novel 520 5200 novel 5200 5200 novel 5200 novel web

Www.520books.com

http://www.cnblogs.com/goodchenqing/

Http://blog.sina.com.cn/goodchenqing

http://goodchenqing.bokee.com/

http://blog.csdn.net/abc288abcd/article/category/2786567


You can create multiple cameras and assign different depths to each one. The camera is drawn in depth from low to high, in other words, a camera with a depth of 2 will be drawn on a camera with a depth of 1. You can adjust the value of a standard viewport rectangle (referring to the previous list of properties) to change its size and its position on the screen. This allows you to create multiple small windows, such as a missile controller, a small map window, a rearview mirror, and so on.

Unity3d Learning Tutorial C # Script control camera

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.