国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 應用 > 應用軟件 > 正文

Unity3D 沖鋒效果、角色拖尾效果

2024-07-16 17:46:18
字體:
來源:轉載
供稿:網友

《魔獸世界》,本人最喜歡的網絡游戲,如果你玩過戰士,你一定對戰士的沖鋒非常熟悉,現在接觸 Unity3D,因為最近用到了刀光、拖尾特效,所以就想做一個類似戰士的沖鋒效果,在本場景用到的拖尾效果可以查看我的另一篇文章,里面有詳細的介紹,刀光效果來自 Unity3D Assets 商店,只是把原作者的例子代碼整理了一下,變得非常簡單實用的類。

最終效果如下:

先來搭建我們的場景,如圖:

然后給角色的模型添加一個空對象,并且加上 MeshRender,并且設置好材質為 WeaponTrail,另外給這個空對象添加 WeaponTrail.cs 對象,設置好相關屬性,如圖:

下面的代碼是修改另一篇文章的 TrailsBladeMaster.cs 類,新的代碼如下:


復制代碼代碼如下:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
[AddComponentMenu("PocketRPG/Blade Master")]
public class TrailsBladeMaster : MonoBehaviour
{
/// <summary>
/// 拖尾效果
/// </summary>
public WeaponTrail weaponSwipe;
public AnimationClip idleClip;
public AnimationClip runClip;
/// <summary>
/// 移動速度
/// </summary>
public float speed = 20.0f;
public Camera mainCamera;
private Animation animation;
protected TrailsAnimationController animationController;
protected CharacterController characterController;
/// <summary>
/// 運行狀態
/// </summary>
private bool isMoving = false;
/// <summary>
/// 目標位置
/// </summary>
private Vector3 targetPosition;
/// <summary>
/// 移動向量
/// </summary>
private Vector3 moveDirection;
protected void Awake ()
{
this.animation = this.GetComponent<Animation> ();
this.animationController = this.GetComponent<TrailsAnimationController> ();
this.characterController = this.GetComponent<CharacterController> ();
this.animation.CrossFade (this.idleClip.name);
}
protected void Start ()
{
if (this.weaponSwipe != null) this.animationController.AddTrail (this.weaponSwipe);
}
protected void Update ()
{
if (!this.isMoving && Input.GetMouseButtonDown(0))
{
this.targetPosition = this.GetWorldPosition();
if(this.targetPosition != Vector3.zero)
{
this.isMoving = true;
this.moveDirection = (this.targetPosition - this.transform.position).normalized * this.speed;
this.transform.rotation = Quaternion.LookRotation(new Vector3(this.moveDirection.x, 0f, this.moveDirection.z));
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 横峰县| 阿鲁科尔沁旗| 太仆寺旗| 潼南县| 新宁县| 萨迦县| 刚察县| 休宁县| 中西区| 旅游| 文安县| 进贤县| 东安县| 鲁甸县| 琼中| 隆德县| 内江市| 南乐县| 德州市| 高平市| 广河县| 中牟县| 海盐县| 凤凰县| 西峡县| 家居| 顺昌县| 大港区| 长岭县| 平武县| 东光县| 瓦房店市| 湘潭市| 常州市| 朝阳县| 台中市| 台安县| 宁乡县| 镇宁| 桃园市| 普格县|