您当前的位置: 首页 > 

开发游戏的老王

暂无认证

  • 3浏览

    0关注

    803博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Godot特效:刀光(四)着色器及代码部分 方法二

开发游戏的老王 发布时间:2019-12-15 16:24:41 ,浏览量:3

写完《Godot特效:刀光(三)着色器及代码部分 方法一》,发现有点麻烦。要通过GDScript旋转然后把值通过uniform 传递到Shader中,与其如此直接旋转模型,岂不是更简单。

所以把上文的方法修改了一下,材质直接用自带的SpatialMaterial

vfx_slash代码

代码比以前更简单了

extends MeshInstance

#var material:Material
var tween : Tween
export var init_degree :float = 0
export var final_degree :float = 90
export var duration:float = 0.2

func _ready():
	tween = Tween.new()
	add_child(tween)
	tween.connect("tween_all_completed",self,"hide")
	hide()

func play():
	show()
	tween.interpolate_property(self,"rotation_degrees",Vector3(0,init_degree,0),Vector3(0,final_degree,0),duration,Tween.TRANS_LINEAR,Tween.EASE_IN)
	tween.start()
参数

这样直接调节初始角度和最终角度更加直观了

在这里插入图片描述

最终效果

在这里插入图片描述

关注
打赏
1656935939
查看更多评论
立即登录/注册

微信扫码登录

0.0395s