Special Effect on sword marks generated by Unity3D weapons

Source: Internet
Author: User




Currently, three methods are available for this effect.

1. follow special effects

2. The program implements the dynamic surface to process the sword marks animation.

3. The art implements the sword mark animation and directly sits in the Model Animation (because I won't do the art, so ignore it)

 

The so-called special effect of sword marks is to follow the weapon's sword trajectory. In this case, we need to find the root node of the weapon's sword trajectory. As shown in, first find the root node of the weapon model. If you cannot find it, ask the model artist. He must know the unity3d blog.

Then, create an empty object "a" (just start one) and place it under the weapon model. The Position and Rotation of Transform are both changed to 0 0 Scale and changed to 1 1 1.


1. follow special effects

Unity comes with a component called "Trail Render", that is, it follows the special effect and can follow the Untitled movement to produce a drag-and-Seek effect. Then, use Component-> Effects-> Trail Render to add the tail components to the empty model just created. Time is the Time of a follow. Start Width and End Width can adjust the Width of the tail.

How about running it directly? Is the special effect of the sword mark available? However, this effect is somewhat limited, because the weapon will rotate itself when it is waving, but this particle effect will not apply the angle of the weapon's rotation. It only keeps following a weapon point. What we need is not only to follow but also to maintain the same angle as the original model, so I gave up this method to create a sword mark.

2. Use programs to dynamically generate a surface to achieve the special effect of sword marks

Later, I found a free example with a sword mark in Unity AssetStort. I can directly search for Pocket RPG Weapon Trails to see it, next I will talk about how to quickly add the special effect of the sword marks in this example to your project and change the component ". Unity3d Official Website


Then, bind the AnimationController to the model for which you want to play the special effect of the sword marks, and write a Test Script Test. cs.

 
Test. cs

Using UnityEngine;
Using System. Collections;

Public class Test: MonoBehaviour
{

Public WeaponTrail;
Protected AnimationController animationController;

Void Start ()
{
AnimationController = GetComponent <AnimationController> ();
AnimationController. AddTrail ();
// Set the tail time
A. StartTrail (0.5f, 0.4f );
// Set the playback time
A. SetTime (0.5f, 0.2f, 0.2f );
Animation. Play ();
}
}

In addition, remember to modify the coordinates of the dynamic grid. In this example, the object "a" is used ". During the modification, you can play the game by frame (shortcut: Command + shift + p) until the following is displayed, and the angle of the network surface of the sword mark is always the same as that of the weapon. Different models may have different angles. You need to adjust them here.



There is a new Animation system added to Unity4. Now, when you place the old Model Animation in the project, you will find that it is not an Animation component, but an Animation or. You can't play an animation using the previous method, unless you manually change the model type to Rig-> Legacy, but if you have many models and animations, programs cannot be manually modified one by one. So I wrote the following simple script to automatically modify the type when the model is dragged into the Project view. Place the following script in the Project view Editor folder. If not, create one.

Using UnityEditor;

Public class EditA: AssetPostprocessor
{
Public void OnPreprocessModel ()
{
ModelImporter modelImporter = (ModelImporter) assetImporter;
// Here is the scaling ratio of the model. The default value is 0.01. Here I changed it to 1.
ModelImporter. globalScale = 1f;
// Modify the model type here
ModelImporter. animationType = ModelImporterAnimationType. Legacy;
}
}

 

Related Article

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.