bugfix enemy spawner
This commit is contained in:
parent
5b659d7b9c
commit
2fd199612b
3 changed files with 7 additions and 6 deletions
|
|
@ -24,7 +24,6 @@ func _process(delta: float) -> void:
|
|||
func hit(_proj: PlayerProjectile, damage: float) -> bool:
|
||||
health -= damage
|
||||
if health <= 0.:
|
||||
print("boom!")
|
||||
SignalBus.building_destroyed.emit(self)
|
||||
collision_layer = 1 # World collision only
|
||||
|
||||
|
|
|
|||
|
|
@ -30,11 +30,12 @@ func _process(_delta: float) -> void:
|
|||
|
||||
var col_mask := 16 # floor collision layer
|
||||
var params := PhysicsRayQueryParameters3D.create(
|
||||
v, v + Vector3.DOWN * 100., col_mask
|
||||
v, v + Vector3.DOWN * 100., 1 # detect any level geometry
|
||||
)
|
||||
var raycast := get_world_3d().direct_space_state.intersect_ray(params)
|
||||
|
||||
if not raycast.is_empty():
|
||||
# if the raycast hit and the hit was the floor...
|
||||
if not raycast.is_empty() and raycast.collider.collision_layer & col_mask:
|
||||
var hitpos: Vector3 = raycast.position
|
||||
|
||||
if points.size() < MAX_CACHED_POINTS:
|
||||
|
|
@ -45,13 +46,15 @@ func _process(_delta: float) -> void:
|
|||
doomed_point_idx = doomed_point_idx % MAX_CACHED_POINTS
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
if points.is_empty(): return
|
||||
if points.is_empty():
|
||||
push_warning("tried to spawn enemy, but can't find a point!")
|
||||
return
|
||||
|
||||
var pos: Vector3 = points.pick_random()
|
||||
pos += Vector3.UP * 0.02
|
||||
var scene := preload("res://enemies/police_car/police_car.tscn")
|
||||
var car: Node3D = scene.instantiate()
|
||||
car.global_position = pos
|
||||
car.position = pos
|
||||
get_tree().current_scene.add_child(car)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -116,7 +116,6 @@ func _process_cam_shake(delta: float) -> void:
|
|||
camera_transform.basis.x * x + \
|
||||
camera_transform.basis.y * y
|
||||
|
||||
print("v = ", v)
|
||||
%Camera3D.position += v * .5
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue