bullet visible by distance

This commit is contained in:
derek
2024-07-17 12:46:02 -05:00
parent a917dd2c88
commit c959835b40
4 changed files with 9 additions and 3 deletions

View File

@@ -6,6 +6,8 @@ var random_spread_amt
var bullet_damage
var instance_bullethole
var bullet_force_mod = 1.0
var distance_from_player
var player
@onready var mesh = $gunbullet1
@onready var ray = $RayCast3D
@@ -39,8 +41,10 @@ func _process(delta):
position += transform.basis * Vector3(0, 0, -bullet_speed) * delta
rotation.x = clamp(rotation.x - delta * bullet_drop,deg_to_rad(-90),deg_to_rad(90))
await get_tree().create_timer(.02 * Engine.time_scale * (150/bullet_speed)).timeout
visible = true
distance_from_player = abs(self.global_position - player.global_position)
if distance_from_player.x > 2 or distance_from_player.y > 2 or distance_from_player.z > 2:
visible = true
if ray.is_colliding() and !ray.get_collider().is_in_group("player"):