Godot3で花火模様を描いて一時停止し、プレイヤーをゆっくり狙う弾
幾何学模様を描いて停止
動き出す時に、プレイヤーを狙う
幾何学模様を描く処理だけ書けば、既存の仕組みの組み合わせただけ
code:py
extends EnemyBase
export(int) var bullet_speed = 55
export(int) var spread_num = 22
export(int) var bullet_num = 15
export(int) var stop_time = 5
onready var use_bullet = preload("res://Scenes/Bullets/E_Bullet_red_6x6.tscn")
func _shoot(player):
# 幾何学模様を描いた後、しばらく停止してからプレイヤーを狙って動く
var direction_list = []
var rand_direction = Vector2(floor(rand_range(-1, 1)), floor(rand_range(-1, 1)))
if rand_direction == Vector2.ZERO:
rand_direction = Vector2.ONE
for i in spread_num + 1:
direction_list.push_front(rand_direction.rotated(i * (PI * 2 / (spread_num + 1))))
for i in bullet_num:
for direction in direction_list:
var bullet = use_bullet.instance()
bullet.is_stop = true
bullet.speed = bullet_speed
bullet.dir = (player.global_position - global_position).normalized()
var timer := Timer.new()
timer.connect("timeout", bullet, "_on_stop_timer_timeout")
timer.wait_time = stop_time
timer.one_shot = true
timer.autostart = true
bullet.add_child(timer)
_add_bullet_to_root(bullet)
bullet.position += (5 * direction) * (i+1) + direction.rotated(PI/7) * sin(PI/8 * i) * 25
yield(get_tree().create_timer(.01), "timeout")
https://gyazo.com/8496ce1c11f0d73cec8967773f01ee70