我如何在游戏中以编程方式使用法术效果

问题描述:

我如何在游戏中以编程方式使用法术效果

how i can work programaticly with spell effect in game

我的效果看起来像

i have a effect look like this spell effect

我想知道如何改变咒语的范围.喜欢改变距离的颜色或者当你运行一些这个效果去透明,10秒后去淡化

i want to know how i can change the cale of the spell . like change color in distance or when u run some this effect goes to transparent and after 10 sec go to fade

看看这张照片中的咒语和武器动画效果(如火或冰效果)

or look at this spell and wepon in this pic like when you have a small wepon and u add a animation effect on it ( like fire or ice effect )

如何根据 wepon 的大小更改动画

how you change the animation base on the size of the wepon

我不知道我必须如何实现它

i have no idea how i have to implement that

提前致谢

[由 Spektre 编辑] 根据评论,我会将问题文本更改为如下所示:

  • 我需要/想要为游戏或其他任何东西编写法术效果可视化...
  • 执行此操作的常见/常用方法是什么(算法、图形技术)
  • 想要实现冰/火/???效果
  • 以射线/波/场/锥体的形式...
  • 理想情况下是通过单个可配置的效果例程(我猜是这个)
  • 还有其中一些效果的确切名称是什么,所以我可以自己搜索它们
  • 我想使用 Unity3D 环境

这是我想知道如何制作动态法术效果的方式

this is the way i want to know how i can make an dynamic spell effect

嗯,有很多方法可以解决这个问题.我不是该领域的专家,也不是 Unity3D 用户,所以我坚持基础:

well there are many approaches for this. I am no expert in the field and not a Unity3D user so I stick to basics:

  1. 粒子系统

这是一个可视化粒子(许多小的移动物体)的引擎.它用于许多效果,例如:火箭油门、火、照明、变化的辉光等等.诀窍是使用混合,所以每个粒子通常是半透明的球.外面更透明,里面更结实.当您将更多粒子靠近在一起时,它们会混合成所需的连续效果.

It is an engine which visualize particles (many small moving objects). It is used for many effects like: rocket throttle,fire,lighting,changing glow,and many more. The trick is the use of blending so each particle is usually semi transparent ball. More transparent on the outside and more solid on the inside. When you draw more particles close together they blend to the desired continuous effect.

这可以通过单纹理QUADTRIANGLE 来完成.纹理可以是带有 alpha 通道编码透明度的白色,因此可以在不改变纹理的情况下对效果的颜色进行编码.颜色、大小和运动模式可以彼此不同,也可以随时间而不同.这三个参数定义了效果外观,例如您想将电射线从施法者投射到目标,因此运动模式为 LINE.现在用一些随机数稍微扭曲那条线,这样 LINE 变成了一个 POLYLINE 并且在这个 POLYLINE 的顶点上你有时可以释放一个粒子在持续时间有限的随机方向上,所以它会像一些火花(不要忘记及时降低它们的大小,以便它们消散).此外,您还必须试验沿 POLYLINE 的主要粒子流的速度和大小/颜色,使其看起来正确.一些效果需要将几个不同的粒子流组合在一起.

This can be done by single textured QUAD or TRIANGLE. The texture can be white color with alpha channel coded transparency so color of the effect can be coded without change in the texture. Color,size and movement patterns can differ to each other and also with time. These three parameters define the effect look for example you want to cast a electric ray from caster to target so the movement pattern is LINE. Now distort that line a little by some random numbers so the LINE becomes a POLYLINE and on the Vertex of this POLYLINE you can sometimes free a particle in random direction with limited duration so it will be like some sparks (do not forget to lower their size in time so they dissipate). Also you have to experiment with the speed and size/color of the main particle stream along the POLYLINE so it looks right. Some effect need to combine few different particle streams together.

搜索关键词:粒子系统、RGBA纹理、混合、插值

Search keywords: particle system,RGBA texture,blending,interpolation

这张照片取自问题中发布的链接.这是两个粒子系统的一个很好的例子.黄色直线LINE粒子流和绿色POLYLINE粒子流.主流周围也出现了一些绿色火花.

this picture is taken from the link posted in the question. It is a nice example of two particle systems. Yellow straight LINE particle stream and green POLYLINE particle stream. Also some green sparks around the main stream are present.

纹理动画

您可以在纹理数组中创建一个循环动画(逐个图像),以便在平面上绘制纹理(通常是单个 QUADTRIANGLE)和一段时间后将纹理更改为下一个,通常在上次之后再次从第一个开始.您还可以使用 BLENDing 或 STENCIL 技术来仅绘制效果区域.如果纹理是白色(无色),则可以通过代码调制颜色.这主要用于爆炸,火灾,...

You can have a little cyclic movie (image by image) in an array of textures so you draw the texture on an plane (usually single QUAD or TRIANGLE) and change the texture after some time to the next , and usually after last go from first again. You can also use BLENDing or STENCIL techniques to draw only the effect area. If the textures are white (colorless) then the color can be modulated by code. This is mostly used for explosions, fire,...

这是简单的爆炸电影示例,它不是循环动画,因此在最后一帧后效果停止(爆炸持续时间有限)

this is simple explosion movie example it is not a cyclic animation so after last frame the effect stops (explosion has finite duration)