untiy& Project Sharing & Project explanation Unitz enemy generation System 2 enemy AI logic description __unity

Source: Internet
Author: User

This article is about Unitz's enemy generation System 2 enemy Description


-----------------------------------------------

enemy Zombie (Clone) has many controls (

Animator, (animation control)

Character Controller, (3D personas control)

Human Character, (Control role animation, attack animation, death animation)

Character Motor, (control the movement of the model Movement, state)

ai Character Controller, (AI role control)

network View, (reference 1, 2)

fps Ray Active, (fps ray detection)

Character Foot Step, (control of character's foot)

Audio Source (voice control)

)

----------------------------------------

by Basecharacter Skin

BIP001 (Figure 2

Hitmark (reaction of attack)

)

-bip001 Footsteps (Figure 3 position of enemy footsteps)

-bip001 pelvins (Spine 3D model)

(Figure 1)

(Figure 4)

(Figure 2)

(Figure 3)

(Figure 4)

------------------------------------------------------------

BIP001 's Damage Manage object is (look for the corresponding class from the left red box in Figure 5)

Its parent class Zombie (Clone) (Humancharacter) inherits from CharacterSystem.cs

CharacterSystem.cs inherits from DamageManager.cs

(Figure 5)

(Figure 2)
Bip001 (Fig. 2 Hitmark (reaction of attack))

Using Unityengine;
Using System.Collections;

public struct damagepackage{//structural body Data 4
Public Vector3 Position;
Public Vector3 Direction;
Public Vector3 Normal;
public int Damage;
public string ID;
public string Team;
}

public class Hitmark:monobehaviour
{

Public Damagemanager damagemanage;//Create a variable for a Damagemanager class
Charactersystem:damagemanager
Humancharacter:charactersystem
Damagemanage = Humancharacter of Zombie (Clone)
Public Gameobject Hitfx; Create an object named Hitfx
public float Damagemult = 1;
public bool Freeze = FALSE;

void Start ()
{
if (this.transform.root)//This never returns NULL, if the transformation does not have a parent, it returns itself.
{//Get the parent Damagemanager component
Damagemanage = this.transform.root.getcomponent<damagemanager> ();
} else
{//Get your own Damagemanager component
Damagemanage = this.transform.getcomponent<damagemanager> ();
}
}

public void Onhit (damagepackage pack)
{//damagemanage exists
if (damagemanage)
{///make the injury implement Damagepackage damage value, damagepackage direction, Damagepackage Id,damagepackage's team
Damagemanage.applydamage ((int) (float) pack. Damage * damagemult), pack. Direction,pack.id,pack. Team);
}
if (! Freeze)
{//No freeze, move direction as pack. Direction.normalized
This.transform.position + = Pack. Direction.normalized;//normalized Data 5
}//
if (pack. Normal!= null)
{

Debug.Log ("Start pack.") Normal "+ Pack. Normal);
}
Particlefx (Pack. Position, pack. normal);//damagepackage pack coordinates, normal for Damagepackage pack

}

public void Particlefx (Vector3 position, Vector3 Normal)
{
if (HITFX)
{//hitfx is a particle effect, the effect of blood after being attacked
Gameobject FX = (gameobject) gameobject.instantiate (hitfx, Position, quaternion.identity);//Generate HITFX
Fx.transform.forward = Normal of Normal;//damagepackage
if (normal!=null)
{

Debug.Log ("normal" + normal);
}

Gameobject.destroy (FX, 3);
}
}

}


struct structure (reference 6)

In simple terms. A struct is a structure that can contain different data types. It is a data type that can be defined by itself.
First, the struct can declare different data types in one structure.
The structure variables of the second same structure can be assigned to each other.
Third, save memory space
Iv. high efficiency.

Https://img-blog.csdn.net/20170123000200306?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvQnVsYWRlTWlhbg==/font /5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/center

Https://img-blog.csdn.net/20170123000205822?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvQnVsYWRlTWlhbg==/font /5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/center


Zombie (Clone) has an AI Character controller component that identifies the attack target (shown in Figure 5)

(Figure 5)

Zombie (Clone) has an AI Character controller component that identifies the attack target (shown in Figure 5)

The AI Character Controller component obtains zombie (Clone) of other components Charactersystem components, and then

This Charactersystem component character has a dodamage function to pass an injured parameter (why Charactersystem component has this parameter)

(Figure 6)

(Figure 8)

public class Humancharacter:charactersystem for Zombie (Clone)

The public class Charactersystem:damagemanager

The public void Setupawake ()

The rayactive = this. Getcomponent<fpsrayactive> (); This rayactive obtains the function Dodamage of the fpsrayactive component (Figure 7)

(Figure 7)

In the Fpsrayactive component, there is a detailed definition of the Shootray function (Figure 9), in which the public constructor for the damagepackage variable is changed (Figure 10).


(Figure 9)

(Figure 10)

-----------------------------------------------------------------------------

To sum up
(Big picture)

Controlling the enemy's AI Character control component is the main control of the enemy AI action program, used for Logic loop judgment


-----------------------------------------------------------------------------

Aicharactercontroller





(Right-view picture to enlarge)







(logical summary)



--------------------------------------------------------------------------------

The remaining part of the transmission door:


Resources:

1. Network Views Network view

2. "Tutorials" Unity3d networkview Tutorials

3.transform.root Root

Structure body in 4.Unity (C #)

The difference between normalized and normalize () functions in 5.vector3

6. C # struct and class differences in the detailed

7.

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.