Unity3d Battle Skill System architecture

Source: Internet
Author: User

Everyone in the game, often see a variety of skill effects, far and near attack, very gorgeous, the role of the strike is very appealing to players, in fact, this is what we usually say the combat skills system, if you first go to achieve this battle system, you may feel no place to start, and then be planning the copywriting, foggy, Here I will talk to you briefly about how to set up a skill system.

In the implementation of the battle system, first of all, we must be clear, know how to set up, do not know how to achieve not busy writing code, think clearly and then write.

That now we assume that the implementation of a gun battle system, the first will have a variety of ***,*** launch of the * * * is different, decided that his degree of destruction is different, which involves a * * and hit the object effects. So how do we design?

Let's take a look at what we've achieved:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/57/A9/wKioL1Sh5_OQkctKAAKTrc1BqM8937.jpg "style=" float: none; "title=" 1.jpg "alt=" Wkiol1sh5_oqkctkaaktrc1bqm8937.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/57/AB/wKiom1Sh50CjRF3NAAJxISf_A20648.jpg "style=" float: none; "title=" 2.jpg "alt=" Wkiom1sh50cjrf3naajxisf_a20648.jpg "/>

Next we begin to architect our skills.

First we aim at weapons and destruction, both of which design two base classes to extend different weapons and extend different degrees of destruction.

The code is as follows:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/57/A9/wKioL1Sh6MrCL03lAABx-sgMyzk944.jpg "title=" 3.jpg " alt= "Wkiol1sh6mrcl03laabx-sgmyzk944.jpg"/>

The above is the base class of damage we define four parameters, one is the release of the effect, the second is self, the third is the degree of destruction, the fourth is the goal of destruction.

Our destructive class will inherit from this base class for easy extension, such as our design code:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/57/AB/wKiom1Sh6VaC1FyHAAEV-DeZxI8026.jpg "title=" 5.jpg " alt= "Wkiom1sh6vac1fyhaaev-dezxi8026.jpg"/>

First of all to have a judgment whether the explosion, as well as the radius of the explosion, destruction, activation time, etc., as long as the strength, we should immediately think of using rigibody this rigid body plug-in. Of course, there is a function of destruction in this function, where a collision detection is required, that is, the missile needs to destroy the object needs to be detected according to its collision body.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/57/A9/wKioL1Sh6vGjtoLzAAEgHbRYv_Q221.jpg "style=" float: none; "title=" 6.jpg "alt=" Wkiol1sh6vgjtolzaaeghbryv_q221.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/57/AB/wKiom1Sh6j7iMHe0AACN_V8-5vo245.jpg "style=" float: none; "title=" 7.jpg "alt=" Wkiom1sh6j7imhe0aacn_v8-5vo245.jpg "/>

We need to detect whether a collision has occurred based on the collision body, and determine whether the collision has occurred by Ocollisionenter.

To make the call convenient we implemented a Damagemanager management class

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/57/A9/wKioL1Sh64mxS_DCAADbd219h5w397.jpg "title=" 8.jpg " alt= "Wkiol1sh64mxs_dcaadbd219h5w397.jpg"/>

Used to determine if it is dead.

Next we need to design the weapon base class:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/57/A9/wKioL1Sh68awNVaiAACNelK8uug548.jpg "title=" 4.jpg " alt= "Wkiol1sh68awnvaiaacnelk8uug548.jpg"/>

This also has some parameters, targets, speed axes and so on. Then the realization of our weapons inherits this class as well.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/57/A9/wKioL1Sh8FninyojAAHIYFmME2o884.jpg "title=" 11.jpg "alt=" Wkiol1sh8fninyojaahiyfmme2o884.jpg "/>

The design of the weapon system is complete, and then we need to set up a weapon control class

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/57/AB/wKiom1Sh7zTgbuToAAF_EvXXJhk707.jpg "title=" 10.jpg "alt=" Wkiom1sh7ztgbutoaaf_evxxjhk707.jpg "/>

Used to launch weapons, and we need weapons to emit classes, for this class of design, we also inherit from the weapon base class, in fact, this can be implemented independently:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/57/AB/wKiom1Sh8B3zUeLcAAH17EGNBlo991.jpg "title=" 9.jpg " alt= "Wkiom1sh8b3zuelcaah17egnblo991.jpg"/>

When the explosion, need to involve the use of special effects, if the whole is particles, we do not need script control, if not particles we need script control, that is, explosion class:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/57/A9/wKioL1Sh8X_iDagXAAGjpinChgU750.jpg "title=" 12.jpg "alt=" wkiol1sh8x_idagxaagjpinchgu750.jpg "/> Explosion classes need to be bound to special effects, a simple weapon system is done. In fact, the complexity of the skill system just follow this idea to expand, the simple skill system has been realized, the complex will not be far away.



This article is from the "Kaiyukan mobile" blog, so be sure to keep this source http://jxwgame.blog.51cto.com/943299/1597574

Unity3d Battle Skill System architecture

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.