Bullet rain is denser and its bullets are no longer stopped by anything
Interval dropped from 1.0s +- 0.6 to 0.4s +- 0.25 (about 2.5 bullets per second instead of 1), which measured 13 drops in 6 seconds versus 6 before. bullet.gd gained stop_on_obstacle (default false): the probe raycast is disabled, so rain bullets fall straight through terrain and ropes and are only recycled by their lifetime or by dropping past despawn_y. Verified a bullet falling from y=190 goes through the floor at y=225 and despawns at y=340. Also picks up the editor changes: the rope tiles were removed from level 3 and a few nodes gained unique ids.
This commit is contained in:
+10
-3
@@ -1,6 +1,6 @@
|
||||
extends Area2D
|
||||
|
||||
## 弹幕子弹:直线飞行,碰到玩家扣血,撞到地形或超时消失。
|
||||
## 弹幕子弹:直线飞行,碰到玩家扣血。
|
||||
## 贴图是代码生成的实心圆,不需要额外美术素材。
|
||||
|
||||
@export var speed: float = 70.0
|
||||
@@ -8,6 +8,11 @@ extends Area2D
|
||||
@export var lifetime: float = 8.0
|
||||
@export var radius: int = 3
|
||||
@export var bullet_color: Color = Color(1.0, 0.35, 0.7)
|
||||
## 撞到地形/绳子之类的障碍就消失。
|
||||
## 关掉(默认)的话子弹会**穿过一切**,只靠存活时间和出界来回收
|
||||
@export var stop_on_obstacle: bool = false
|
||||
## 掉到这个世界 y 以下就自动回收(默认在关卡底部之外)
|
||||
@export var despawn_y: float = 340.0
|
||||
|
||||
var direction: Vector2 = Vector2.LEFT
|
||||
|
||||
@@ -48,6 +53,8 @@ func _ready() -> void:
|
||||
circle.radius = float(radius)
|
||||
hit.shape = circle
|
||||
_probe = get_node_or_null("Probe") as RayCast2D
|
||||
if _probe != null:
|
||||
_probe.enabled = stop_on_obstacle
|
||||
body_entered.connect(_on_body_entered)
|
||||
|
||||
|
||||
@@ -59,12 +66,12 @@ func launch(dir: Vector2, spd: float = -1.0) -> void:
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
_age += delta
|
||||
if _age >= lifetime:
|
||||
if _age >= lifetime or global_position.y > despawn_y:
|
||||
queue_free()
|
||||
return
|
||||
|
||||
var step := direction * speed * delta
|
||||
if _probe != null:
|
||||
if stop_on_obstacle and _probe != null:
|
||||
_probe.target_position = step * 1.5
|
||||
_probe.force_raycast_update()
|
||||
if _probe.is_colliding():
|
||||
|
||||
Reference in New Issue
Block a user