"Unity" 4.4 Add role Controller

Source: Internet
Author: User

Categories: Unity, C #, VS2015

Date Created: 2016-04-10 I. INTRODUCTION

After the basic design of the scene, it is generally necessary to run first to see how the effect, that is, let the scene "moved" to facilitate the observation of different locations, rather than just observe the fixed camera position of the rigid board scene.

This is the function of the role controller (in fact, not just these features).

Unity has helped you design the role Controller component (characters), you just need to import it, and then you can use it directly. Ii. importing Unity's own pin-color controller

To make the scene you're designing move, you just need to import the characters component from unity, as shown in:

or right-click the Assets folder under Project view, and the same context menu pops up.

In the next window that pops up, just click "Import" to:

Third, unity comes with the classification of the role controller

Unity's own pin-color controller comes in two types: 1th-person and 3rd-person.

1.1th person

Unity's own first-person presets (prefabs) have helped you achieve the common functionality you need, and you can use it without having to write any more scripts, just drag and drop this preset into your scene.

To use the first-person role:

(1) Create a suitable scene where you can walk around the ground.

(2) Drag and drop the Firstpersoncharacter preset into the scene.

(3) Delete the "Main Camera" that was added automatically when the scene was created. This is because the first person character preset contains its own camera, so the "Main camera" is useless after adding firstpersoncharacter.

First-person roles are jointly initiated by the following components to initiate related actions:

Scripts in the FirstPersonCharacter.cs file: moving, shooting, and jumping.

Scripts in the SimpleMouseRotator.cs file: Turn around (arrow keys), Stand up and ready to jump (up and DOWN ARROW keys).

In addition, Unity's own first-person character also includes bobbing effects (Head Bob, also known as Bob) and footstep sounds (optional) when walking around. You can decide whether to use these effects as needed.

Each script component of Unity's own first-person role provides a number of settings that can be directly adjusted, and what you need to do is simply to change the values in the viewer. For example, modify the movement speed, bounce energy, Bob shaking form 、...... such as

Also, the "0 frictional resistance" (zero friction) and the maximum friction resistance (max friction) physical material that need to be referenced in the script are also included, and you don't need to design the material yourself.

2.3rd person

The following chapters are introduced again. Iv. examples (Demo05)

This example shows how to add a 1th person role controller to the scene.

1. Add 1th person presets

Drag and drop the "Fbscontroller" preform under characters into the hierarchy view as shown in:

2. Delete Main Camera

Delete the "Main Camera" that was added automatically when the scene was created.

3. Modify the 1th person parameter

4. Preview observation Effect

Press the play button to preview.

When previewing, you can either move with the mouse or use the UP or DOWN ARROW keys.

Press the ESC key, and then click the Play button again with the mouse to end the preview.

"Unity" 4.4 Add role Controller

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.