Unity Angrybots Angry robot Demo Research

Source: Internet
Author: User
Tags reflection

As Unity's early classic demo, it has been used since 3.5 to version 4.7.x. But some of its internal practices are very unreasonable. For example, using too many root directories,

Create monsters and players without Spawnpoint,ai,checkpoint code implementation is too casual, code naming style weird and so on.

And there are a lot of related learning articles on the Internet, so I streamlined it, and learned and recorded some useful parts.

1. Lead Weapon part

Weaponslot is the main gameobject node of the weapon, which has various related scripts.

Where the sighting line (Laserscope) is implemented by Linerenderer:

Its shader adds an extra noise effect and then changes the UV position and zoom through the script. The script is Laserscope,shader path angrybots/fx/laserscope

The points mapped on the target use patches, and the direction of the Normals is modified based on the rays emitted from each frame. Implementation is also in the Laserscope.

In addition, in order to prevent the overhead of multiple rays per frame, a script Perframeraycast cache the ray content and update each frame.

function Awake () {    tr = transform;} function Update () {    //Cast a ray to find out the end point of the laser    hitinfo = Raycasthit ();    Physics.raycast (Tr.position, Tr.forward, hitinfo);} function Gethitinfo (): raycasthit {    return hitinfo;}

2. Rainwater Realization

Rain is not the mainstream of the camera with a massive particle emitter. But with the movement of the mesh to achieve

The specific script is in Rainbox and gets the stored raindrop mesh through Rainmanager. Each mesh contains a number of raindrop patches

The ripples that fall on the ground are also mesh with several patches, and several. Its script in Rainsplashbox, through the shader (Angrybots/fx/rainsplash) to play the ripples of the pattern graph

Different playback times are obtained in shader according to different coordinates:

Half timeval = frac (_time.z * 0.5 + v.texcoord1.x) * 2.0;

Another interesting script for looping through array elements is:

int mindex;void Update () {    var collectionlength = 5;    var a = (mindex++)% Collectionlength;    Debug.Log ("A:" + a);//0,1,2,3,4 ... 0,1,2,3,4}

3. Reflection implementation

Did not expect to actually do a real-time reflection:

The method is more classic, through a reflective camera to obtain the reflective content, and the layer mask to filter the ground and other content, through the reflection matrix to obtain the reflection position.

The script is in Reflectionfx with the following parameters:

Several important parameters:

Reflective object, which is simply a recent position with the elements in this set, and a reflection point as a horizontal reference.

Reflective materials reflective material, used to throw the resulting rendertexture into the inside, Reflecction Sampler is the assigned Tex channel name.

The replacement Shader handles the reflected Shader, and if it is to be used, it can be copied directly from the project.

Now that it has reached Unity5, specular reflection has been handled a lot, with two enumerations:

High-quality specular reflection in the blacksmith with blur effect: http://www.cnblogs.com/hont/p/5658491.html

Specular reflection with reflective probe: http://www.cnblogs.com/hont/p/6091055.html

In addition, there is an article on traditional specular reflection implementation: http://gad.qq.com/article/detail/7157554

4. Additional content

1. Game Image Quality Management is located in Qualitymanager, where the Shaderdatabase script stores shader information and modifies the shader maximum Lod in bulk when modifying quality.

A mapping table of physical materials and sound effects is stored in the 2.MaterialImpactManager.

3.ReflectiveBackgroundArbitrary shader directly read to Lightmap, for have to take lightmap demand shader, can refer to this.

4. The current environment of the hue and other content management in the Moodbox, including Moodboxmanager, this set of things collectively referred to as Moodbox System. I'm not sure if this is the official name of mood, write it down first.

There is an export obj tool under 5.Editor. After export, under the Exportedobj folder, you can export the. obj format model directly, but many small part models, not consolidated.

The 6.Editor also has a Sky box generator and a cubemap generator that provides only one point to assist in generating

7.Patrol Route patrol Route script, can also draw curves

Unity Angrybots Angry robot Demo Research

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.