afterimage
parent
8885f58b83
commit
a363d83355
@ -0,0 +1,9 @@
|
|||||||
|
[gd_scene load_steps=3 format=3 uid="uid://b12fa5bpdmhms"]
|
||||||
|
|
||||||
|
[ext_resource type="SpriteFrames" uid="uid://cwe8setoi6bd" path="res://resource/animation/character/hero01_move.aseprite" id="1_1twno"]
|
||||||
|
[ext_resource type="Script" path="res://script/effect/afterimage.gd" id="2_grtq1"]
|
||||||
|
|
||||||
|
[node name="AfterImage" type="AnimatedSprite3D"]
|
||||||
|
sprite_frames = ExtResource("1_1twno")
|
||||||
|
animation = &"idle_loop"
|
||||||
|
script = ExtResource("2_grtq1")
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
@onready var afterimage = preload("res://scene/effect/afterimage/normal.tscn")
|
||||||
|
|
||||||
|
@onready var character = (get_owner() as Character)
|
||||||
|
@onready var view = (%View as View)
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
pass
|
||||||
|
|
||||||
|
func cast_after_image():
|
||||||
|
var new_afterimage = afterimage.instantiate() as Afterimage
|
||||||
|
new_afterimage.position = character.view_pos()
|
||||||
|
new_afterimage.name = "afterimage"
|
||||||
|
new_afterimage.velocity = character.velocity / 4
|
||||||
|
view.clone(new_afterimage)
|
||||||
|
SignalManager.effect_create.emit(new_afterimage)
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
extends AnimatedSprite3D
|
||||||
|
class_name Afterimage
|
||||||
|
|
||||||
|
@export var duration_max:float = 0.2
|
||||||
|
@export var is_moving:bool = true
|
||||||
|
|
||||||
|
var duration:float
|
||||||
|
var velocity:Vector3
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
duration = duration_max
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
if is_moving:
|
||||||
|
position += velocity*delta
|
||||||
|
|
||||||
|
var rate = duration / duration_max
|
||||||
|
modulate.a = rate
|
||||||
|
|
||||||
|
duration-=delta
|
||||||
|
if duration<=0:
|
||||||
|
queue_free()
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
extends Node3D
|
||||||
|
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
SignalManager.effect_create.connect(on_effect_create)
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
pass
|
||||||
|
|
||||||
|
func on_effect_create(effect:Node3D):
|
||||||
|
add_child(effect)
|
||||||
Loading…
Reference in New Issue