bullet visible by distance
This commit is contained in:
@@ -396,7 +396,7 @@ script = ExtResource("2_6i1l4")
|
||||
gun_name = "Mac 10"
|
||||
recoil_amount = 1.0
|
||||
max_ammo = 30
|
||||
bullet_drop = 0.1
|
||||
bullet_drop = 0.07
|
||||
random_spread_amt = 0.5
|
||||
fire_pitch_scale_amt = 0.1
|
||||
flare_light = NodePath("mac10/SpotLight3D")
|
||||
|
||||
@@ -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,7 +41,9 @@ 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
|
||||
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
|
||||
|
||||
|
||||
|
||||
@@ -105,6 +105,7 @@ func shoot(player,delta):
|
||||
instance_bullet.bullet_damage = bullet_damage
|
||||
instance_bullet.bullet_force_mod = bullet_force_mod
|
||||
instance_bullet.instance_bullethole = bullethole.instantiate()
|
||||
instance_bullet.player = player
|
||||
get_tree().get_root().add_child(instance_bullet)
|
||||
|
||||
# Casing transform
|
||||
|
||||
@@ -152,6 +152,7 @@ func fire(delta):
|
||||
instance_bullet.bullet_damage = bullet_damage
|
||||
instance_bullet.random_spread_amt = random_spread_amt
|
||||
instance_bullet.bullet_force_mod = bullet_force_mod
|
||||
instance_bullet.player = player
|
||||
instance_bullet.instance_bullethole = bullethole.instantiate()
|
||||
get_tree().get_root().add_child(instance_bullet)
|
||||
player.weapon_recoil()
|
||||
|
||||
Reference in New Issue
Block a user