[Unity3d] Unity3d Paladin Simulation game development of the Fairy Spirit reach Authority Island

Source: Internet
Author: User

Hello, I am Qin Pei. Please pay attention to my blog. My blog address is Blog.csdn.net/qinyuanpei.

In the previous article. We have implemented a self-defined role Controller "[Unity3d]unity3d game development of imitation Paladin character control effect" and the effect of the role of Death "[Unity3d]unity3d game development of imitation Paladin character death effect realization". Today we continue to do something related to the Paladin, first we look at a picture:


This picture is the first labyrinth scene of the Paladin--the Lotus pond of fairy-ling island.

The male lead Li Carefree for aunt to seek medicine alone, in the front of the grass after the demon battle, Lee Carefree came to the Lotus Pond, the solution of the maze is very easy, ride in the Lotus Pond Reed mat to different places, and then use the broken day hammer to break five of the asura like, the path to the Fairy Island will be opened, It is in the Fairy Ling Island Lee Carefree Encounter is bathing Zhaoling son. The story of the Paladin biography begins. All right. Here's the story first, let's take a look at a very important message here: Lee Carefree stepping on the reed mat to reach different places. Then use the broken day hammer to break the statue open the body.

If we take what we want, we can go to different places by stepping on a reed mat. Well, we're going to implement a simplified "fairy Island" today!

So how do you do it? I do not know if you remember me in the "[Unity3d]unity3d game development based on the Itween implementation of pathfinding function" This article mentioned in the search method, in this article. The effect we've finally achieved is this:


Now, let's take the elements of the Lotus Pond Abstract: Each pillar can be regarded as a path-finding node, and the reed mat can be seen as a gameobject that binds the pathfinding component. The only difference is that the reed mat here needs our character to stand up and let it move. And our game body in this article is self-moving.

OK, now let's start to implement this function. Let's start by creating a scene that looks like this:


We placed 8 stone pillars and two reed mats in the water, and when the game started, the player took control of the character and walked onto the reed Mat. The reed Mat will deliver the character to the last pillar position according to a predetermined route, at which point the player can control the character to reach the opposite shore.

When the player is on the reed mat again, the reed Mat will send the character back to the starting position.

When the reed cushion is in the moving state, the character can rotate in four directions, and the range of activity is limited to the reed mat. Good. Explain the scene, we take down the principle of explanation:

1. Role control

Use the role controller implemented in the [Unity3d]unity3d game development of imitation Chinese Paladin character control effect] to control the behavior of the role.

2, seek the realization of the road

Used as the base script for the Pathfinding component implemented in the [Unity3d]unity3d game development based Itween implementation pathfinding feature]. This section is expanded and intact on this basis. Ensure that the character is free to move

Based on the above two principles, we will write today's script as follows:

Using unityengine;using System.collections;public class Transportscript:monobehaviour {//Pathfinding component node public transform[] mpaths;//Reed Pad Transmitter Private Transform mtransportor;//transmitted role public Transform mtransportplayer;//beginnings Vector3 startpoint=new Vector3 (0f,0.5f,-13f);//End Vector3 endpoint=new Vector3 (0f,0.5f,10f);//define the direction type of the move: from the start to the end of 0, from the end point to the starting point of 1private int movetype=0;//defines the move state of the flag variable private bool ismoving=false;//stores the hash table set for a Hashtable private Hashtable args=new Hashtable (); void Start (    {//Get transmitter mtransportor=this.transform;//initialize pathfinding plugin Hashtable args = new Hashtable (); Sets the point of the path, args. ADD ("path", mpaths);//The set type is linear and the linear effect is better.

Args. ADD ("Easetype", iTween.EaseType.linear);//Set the speed of the pathfinding to args. ADD ("Speed", 2.5f); The overall time of the move. Assume that the priority Speedargs with speed co-existence. ADD ("Time", 10f);//whether to go from the original position to the position of the first point in the path of args. ADD ("Movetopath", true);//delay run time args. ADD ("delay", 0.1f);//The process of moving the face toward a point of args. ADD ("Looktarget", vector3.up);//three loop type none Loop Pingpong (General loop back and forth) args. ADD ("Looptype", "pingpong");//Whether the model is always facing the direction of the face target//Assuming you find that your model is in the same direction when you are searching for the road. Then be sure to open this args. ADD ("Orienttopath", true); Itween.moveto (Gameobject,args); Itween.pause ();} void Update () {//If the animation is paused (ismoving==false) {itween.pause () if it is currently in a stopped state; }//From start to finish control if (movetype==0 && mtransportor.position!=endpoint && ismoving==true) {//Do not reach end point continue motion Mtransportplayer.position=mtransportor.position; }else if (movetype==0 && mtransportor.position==endpoint) {//To reach the end of the pause Motion Itween.pause (); Ismoving=false; movetype=1; }//control from end to start if (movetype==1 && mtransportor.position!=startpoint && ismoving==true) {//Do not reach end point continue motion Mtransportplayer.positiOn=mtransportor.position; }else if (movetype==1 && mtransportor.position==startpoint) {//To reach the end of the pause Motion Itween.pause (); Ismoving=false; movetype=0; }}//Move animation void Ontriggerenter (Collider mcollider) {if (mcollider.gameobject.name== "Samuzai") {if (Ismovin) when the character walks onto the reed pad G==false) {ismoving=true; Itween.resume (); }} }}


In the above code, we need to grasp the following points:

1. In the start () method. Our main completion is the initialization of the pathfinding component, where we set the Pathfinding animation to go back and forth, and then control the playback of the animation through the pause (), Resume () method two methods. Since Itween does not provide a way to animate in update (), Itween only supports some of the methods used in the update () method, so that you can learn more about Itween's API documentation on your own.

2, we mainly through the ismoving flag to mark the current state, using the Ontriggerenter () method to infer whether the role on the reed Mat. When a character walks on a reed mat, it starts playing the pathfinding animation.

When the start/end point is reached, the pathfinding animation stops.

Once the character is on the reed mat again, it starts to find the road animation again.

3, we re-update () method by changing the position of the role to achieve the role and the reed Mat synchronous movement, when the start/end point, the pathfinding animation stops until the next time it is triggered.

4, the difference between trigger and collision is that the trigger does not produce force. The Ontriggerenter/ontriggerstay/ontriggerexit method can be used to monitor trigger start, trigger, and end of triggering respectively.

To use trigger, you need to tick the Istrigger option of the collider. The detailed difference I will explain in the later article for everybody.

This article is used in so many things, the basic difficulty is to find the control of the road animation. Because the official did not provide the relevant method. So we can only use the pause (), Resume () method to control the animation of the character. Finally, let's take a look at the effect of the implementation. Does it feel like a fairy spirit? Oh



Finally, a few folk fan game demo:

1, UdK made the Paladin 13 D version of the Fairy island scene

2, u3d production of the Paladin five prequel demo 1

U3d produced by the Paladin five prequel demo 2

Every time I see this. Heart will be filled with a hope that in the lifetime to play a lot of other Paladin, Tage long Line, the dream of sustainable!

Keep working on it!

Like my blog Please remember my name: Qin Yuanpei. My blog address is: Blog.csdn.net/qinyuanpei

Reprint please indicate the source. This article Qin Yuanpei, the source of this article: http://blog.csdn.net/qinyuanpei/article/details/24038749


Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.

Please specify the source and author of the reprint. Thank you!

[Unity3d]unity3d Paladin simulation game development of fairy Spirit to reach authorities island

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.