[Unity&特效]使用Projector投影仪来制作角色脚下的特效圆环以及技能指示器skill indicator
来源:互联网 发布:raphael.2.1.0.min.js 编辑:程序博客网 时间:2024/05/21 07:12
根据参考资料1 里面的,下载 projector 组件
ProjectorCustom Shader在参考资料10
结合参考资料11查看
----------------------------------------------------------------------------------------------------------------------------------------
Projector投影仪的创建 以及 设置
如果 Projector投影仪 如下图设置
设置后效果如图所示
根据 参考资料2,3,4,5,6,使用画图工具 画一个 自己 的圆环
如果设置如下
效果如下所示
新建材质球
----------------------------------------------------------------------------------------------------------------------------------------
技能指示器skill indicator 如何围绕 着 玩家 进行 旋转
设置如下所示
TestRotation 代码如下所示:
using System.Collections;using System.Collections.Generic;using UnityEngine;public class TestRotation : MonoBehaviour { private Vector3 rotationMask = new Vector3(0, 1, 0); //which axes to rotate around private float rotationSpeed = 5.0f; //degrees per second public GameObject rotateAround; private Transform rotateAroundObject; private void Awake() { rotateAroundObject = rotateAround.transform; } // Update is called once per frame void Update () { if (rotateAroundObject) {//If true in the inspector orbit <rotateAroundObject>: transform.RotateAround(rotateAroundObject.transform.position, rotationMask, rotationSpeed * Time.deltaTime); } else {//not set -> rotate around own axis/axes: transform.Rotate(new Vector3( rotationMask.x * rotationSpeed * Time.deltaTime, rotationMask.y * rotationSpeed * Time.deltaTime, rotationMask.z * rotationSpeed * Time.deltaTime)); } }}----------------------------------------------------------------------------------------------------------------------------------------
有两种方式可以使得 旋转 的指示器 停止
1. X,Z的坐标 在一定 的范围 内 满足 条件 ,停止。
2. 比较 两条 直线 (玩家-鼠标,箭头-圆)的角度。Vector3.Angle(line_m_, line_a_);
这样进行设置 ,就可以 使得 Arrow 对象 ,在 X 在一定 范围 的时候 ,就停下来
using System.Collections;using System.Collections.Generic;using UnityEngine;public class TestRotation : MonoBehaviour{ private Vector3 rotationMask = new Vector3(0, 1, 0); //which axes to rotate around private float rotationSpeed = 10.0f; //degrees per second public GameObject centerGO; private Transform centerGO_trans; private Vector3 centerGO_pos; public GameObject arrowGO; private Transform arrowGO_trans; private Vector3 arrowGO_pos; private void Awake() { UpdatePoint(); } // Update is called once per frame void Update() { UpdatePoint(); if (arrowGO_pos.x < 1 && arrowGO_pos.x > 0.9) { Debug.Log("111"); } else { if (centerGO.transform) {//If true in the inspector orbit <rotateAroundObject>: transform.RotateAround(centerGO_pos, rotationMask, rotationSpeed * Time.deltaTime); } else {//not set -> rotate around own axis/axes: arrowGO_trans.Rotate(new Vector3( rotationMask.x * rotationSpeed * Time.deltaTime, rotationMask.y * rotationSpeed * Time.deltaTime, rotationMask.z * rotationSpeed * Time.deltaTime)); } } } private void UpdatePoint() { centerGO_trans = centerGO.transform; centerGO_pos = centerGO_trans.position; arrowGO_trans = arrowGO.transform; arrowGO_pos = arrowGO_trans.position; }}
----------------------------------------------------------------------------------------------------------------------------------------
当下面 的这个 参数 为 -1 的时候,逆时针 旋转,为1 的时候,顺时针旋转
private Vector3 rotationMask = new Vector3(0, -1, 0); //which axes to rotate around
----------------------------------------------------------------------------------------------------------------------------------------
当
当 line_m 和 line_a 都 normalized。
Vector3.normalized
using System.Collections;using System.Collections.Generic;using UnityEngine;public class TestRotation : MonoBehaviour{ private Vector3 rotationMask = new Vector3(0, 1, 0); //which axes to rotate around private float rotationSpeed = 10.0f; //degrees per second public GameObject centerGO;//中心 private Transform centerGO_trans; private Vector3 centerGO_pos; public GameObject arrowGO;//箭头 private Transform arrowGO_trans; private Vector3 arrowGO_pos; public GameObject playerGO;//玩家 private Transform playerGO_trans; private Vector3 playerGO_pos; private Vector3 mouse_pos;//鼠标 private Vector3 line_m;//鼠标 到 玩家的 向量 private Vector3 line_m_;//使其 Y 为0 private Vector3 line_a;//箭头 到 中心 的向量 private Vector3 line_a_;// private void Awake() { UpdatePoint(); } // Update is called once per frame void Update() { Ray MouseRay = UnityEngine.Camera.main.ScreenPointToRay(Input.mousePosition);//场景中必须含有 Canvas,否则无效 RaycastHit raycastHit;//互动物体 碰撞到的物体 Physics.Raycast(MouseRay, out raycastHit, 5000); if (null != raycastHit.transform) { UpdatePoint(); mouse_pos = raycastHit.point; line_m = new Vector3(mouse_pos.x, 0, mouse_pos.z) - new Vector3(playerGO_pos.x, 0, playerGO_pos.z); line_m_ = line_m.normalized; line_a = new Vector3(arrowGO_pos.x, 0, arrowGO_pos.z) - new Vector3(centerGO_pos.x, 0, centerGO_pos.z); line_a_ = line_a.normalized; Debug.Log(" "+ mouse_pos); if (line_a_.x > (line_m_.x -0.1f ) && line_a_.x < (line_m_.x + 0.1f) && line_a_.z > (line_m_.z - 0.1f) && line_a_.z < (line_m_.z + 0.1f) )//就不旋转,否则 则旋转 { Debug.Log("111"); } else { if (centerGO.transform) {//If true in the inspector orbit <rotateAroundObject>: transform.RotateAround(centerGO_pos, rotationMask, rotationSpeed * Time.deltaTime); } else {//not set -> rotate around own axis/axes: arrowGO_trans.Rotate(new Vector3( rotationMask.x * rotationSpeed * Time.deltaTime, rotationMask.y * rotationSpeed * Time.deltaTime, rotationMask.z * rotationSpeed * Time.deltaTime)); } } } } private void UpdatePoint() { centerGO_trans = centerGO.transform; centerGO_pos = centerGO_trans.position; arrowGO_trans = arrowGO.transform; arrowGO_pos = arrowGO_trans.position; playerGO_trans = playerGO.transform; playerGO_pos = playerGO_trans.position; }}----------------------------------------------------------------------------------------------------------------------------------------
当发生旋转的 时候 Arrow对象 的 Rotattion 的Z 发生变化 ,并且 Position 的 X,Z坐标发生变化。只在 世界坐标系 的 X Z 平面上发生变化
所以,要想实现 鼠标 移动 使得 技能指示器 skill indicator 跟随鼠标 的变化 ,而旋转
就得改变 Arrow 对象 的Rotation 的 Z ,以及 Position 的 X 和Z 轴坐标。
参考资料:
1.[Unity&特效]使用Projector投影仪组件在哪里下载
2.
ps怎么画圆形
3.
如何用PS画空心圆
4.
PS中如何填充颜色
5.
如何用PS画箭头
6.
怎样用ps画箭头以及自定义图形
7.
[Unity]空心圆范围内随机生成物品
http://blog.csdn.net/bulademian/article/details/73504204
8.unity 计算两点角度
9.
10.Unity 5 使用Projector实现纹理投射
11.[Unity]2D&3D物体指向indicator鼠标,技能指示器 基础
12.
13.
- [Unity&特效]使用Projector投影仪来制作角色脚下的特效圆环以及技能指示器skill indicator
- [Unity&特效]怎么画圆范围circle range技能指示器skill indicator
- [Unity&特效]使用Projector投影仪组件在哪里下载
- [Unity&]技能指示器skill indicator怎么做
- 使用Unity制作的一个望远镜特效
- 制作技能冷却特效
- Unity如果制作特效
- Unity特效制作规范
- Unity角色残影特效
- NGUI研究之制作转圈的技能CD特效
- 使用纹理制作特效
- 使用纹理制作特效
- 使用纹理制作特效
- 使用纹理制作特效
- 使用纹理制作特效
- 使用纹理制作特效
- NGUI技能冷却CD特效制作
- 使用Unity制作的一个望远镜特效,在狙击手游戏中很常见
- federated存储引擎
- Popwindow弹出框的模板使用
- 最小生成树
- HashMap中插入null key的过程分析
- Maven构建多模块项目
- [Unity&特效]使用Projector投影仪来制作角色脚下的特效圆环以及技能指示器skill indicator
- 简易的SpringMVC基础
- [shader]玻璃效果
- call和apply用法(待修正)
- 水平居中方法
- 获取随机验证码代码
- idea 下使用maven创建工程报错
- 排序算法
- 流式布局的使用