Unity3d the use and description of the program script for moving objects

Source: Internet
Author: User

Welcome to Unity Learning, unity training, Unity Enterprise training and education zone, there are many u3d resources, u3d training videos, u3d tutorials, U3d Frequently asked questions, U3d Project source code, we are committed to creating the industry Unity3d training, learning the first brand.

Last we talked about how to make unity come with a terrain system, then this is a quick way to explain how to use scripting to control.

First, select Gameobject->create other->cube to create a cube.

We save this scenario as TankWar0.2 for version control.

Adjust the position of the cube and the camera so that you can see the camera on the screen roughly.

650) this.width=650; "id=" aimg_4328 "class=" Zoom "src=" http://unity.gopedu.com/data/attachment/forum/201410/18/ 151611aqynatlg9bvcycds.jpg "width=" "style=" border:0px;/>

Drag the Cubemove in the project panel onto the cube to assign it to a block, click Run and try to find that as we press the WASD on the keyboard, the block will change accordingly.

Next we add a script to the camera to control it, but this script is written by unity in advance.

Right-clicking on the project panel, as described in the previous article, we introduced a scripts folder with a Smoothfollow script file that was dragged and dropped onto the Maincamera.

Check Maincamera again to see that there is already a script file attached to it.

Hold the cube on the Hierachy panel and drag it to the target on the script:

650) this.width=650; "id=" aimg_4329 "class=" Zoom "src=" http://unity.gopedu.com/data/attachment/forum/201410/18/ 151735bpe5003t0l8ir4e8.jpg "width=" "style=" border:0px;/>

This enables the script to be associated with a block.

Run the file at this time and we'll find that the camera can move along with the block.

This time again to repeat the above mentioned adding a rigid body, run again, then this small block with a rigid body even if the configuration is complete.


For more highlights, please click http://www.gopedu.com/


Unity3d the use and description of the program script for moving objects

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.