FINALLY FIXED REVOLVER CHAMBER
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -702,7 +702,7 @@ audio_empty = NodePath("Audio/Empty")
|
||||
audio_reload = NodePath("Audio/Reload")
|
||||
|
||||
[node name="mac10" parent="." index="0"]
|
||||
transform = Transform3D(-1.08301e-06, -8.05088e-08, -0.3, -0.0225093, 0.299154, 9.77362e-10, 0.299154, 0.0225093, -1.086e-06, -0.00876398, 0.0748287, -0.0557729)
|
||||
transform = Transform3D(-1.08301e-06, -8.05084e-08, -0.3, -0.0225093, 0.299154, 9.77767e-10, 0.299154, 0.0225093, -1.086e-06, -0.00876398, 0.0748287, -0.0557729)
|
||||
cast_shadow = 0
|
||||
lod_bias = 10.0
|
||||
mesh = SubResource("ArrayMesh_pcg38")
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,86 +0,0 @@
|
||||
extends RigidBody3D
|
||||
|
||||
@export var collision_shape = Node
|
||||
@export var despawning = false
|
||||
@export var despawn_time_s = 10
|
||||
@export_enum("Ammo", "Stamina", "Health", "Money","Weapon") var pickupType: int
|
||||
|
||||
@onready var level_control = get_tree().current_scene
|
||||
@onready var timer: Timer = $Timer
|
||||
|
||||
var pickupable = false
|
||||
var pick_up = false
|
||||
var rand_amt
|
||||
var player_follow
|
||||
var player
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
add_to_group("pickup")
|
||||
add_to_group("spawned")
|
||||
add_to_group("persist")
|
||||
#find player
|
||||
player = level_control.player
|
||||
rand_amt = randi_range(25,100)
|
||||
|
||||
if despawning == true:
|
||||
timer.wait_time = despawn_time_s
|
||||
timer.start()
|
||||
|
||||
func _physics_process(delta):
|
||||
if player_follow != null:
|
||||
if !pick_up:
|
||||
despawning = false
|
||||
angular_velocity = lerp(angular_velocity, Vector3(0,0,0), delta)
|
||||
position = lerp(position, player.item_holder.global_position, 25 * delta)
|
||||
|
||||
if abs(position - player.item_holder.global_position) < Vector3(.5,.5,.5):
|
||||
await get_tree().create_timer(1).timeout
|
||||
position = lerp(position, player.camera.global_position, .01 * delta)
|
||||
await get_tree().create_timer(.01).timeout
|
||||
picked_up()
|
||||
|
||||
|
||||
func picked_up():
|
||||
player.pickup_sound.pitch_scale = 1 + randf_range(-.3,.3)
|
||||
player.pickup_sound.play()
|
||||
Input.start_joy_vibration(0,.1,.1,.1)
|
||||
match pickupType:
|
||||
# Ammo
|
||||
0:
|
||||
var ammo_add_amount : int = (rand_amt * .01) * player.gun.max_ammo
|
||||
level_control.ammo_reserve[level_control.current_gun_index] += ammo_add_amount
|
||||
print("ammo + " +str(ammo_add_amount))
|
||||
# Stamina
|
||||
1:
|
||||
var stamina_add_amount = (rand_amt * .01) * player.MAX_STAMINA
|
||||
player.remaining_stamina += stamina_add_amount
|
||||
print("stamina + " +str(stamina_add_amount))
|
||||
# Health
|
||||
2:
|
||||
level_control.health += 1
|
||||
# Money
|
||||
3:
|
||||
level_control.money += rand_amt
|
||||
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
if despawning == true:
|
||||
collision_shape.disabled = true
|
||||
await get_tree().create_timer(1).timeout
|
||||
self.queue_free()
|
||||
|
||||
func save():
|
||||
var save_dict = {
|
||||
"filename" : get_scene_file_path(),
|
||||
"parent" : get_parent().get_path(),
|
||||
"pos_x" : position.x,
|
||||
"pos_y" : position.y,
|
||||
"pos_z" : position.z,
|
||||
"rot_x" : rotation.x,
|
||||
"rot_y" : rotation.y,
|
||||
"rot_z" : rotation.z
|
||||
}
|
||||
return save_dict
|
||||
@@ -553,10 +553,11 @@ func aim_down_sights(delta):
|
||||
camera.fov = lerp(camera.fov,BASE_FOV - float(gun.fov_zoom_amt),(delta * 5)/Engine.time_scale)
|
||||
gun.position = lerp(gun.position,ADS_POS,delta * 10 / Engine.time_scale)
|
||||
else:
|
||||
gun.position = lerp(gun.position, weapon_start_pos,delta * 2)
|
||||
camera.fov = lerp(camera.fov,BASE_FOV - float(gun.fov_zoom_amt),(delta * 4)/Engine.time_scale)
|
||||
weapon_holder.rotation = lerp(weapon_holder.rotation,Vector3(0,0,0),(delta * 10)/Engine.time_scale)
|
||||
gun.position = lerp(gun.position, weapon_start_pos,(delta * 4)/Engine.time_scale)
|
||||
camera.fov = lerp(camera.fov,BASE_FOV - float(gun.fov_zoom_amt),(delta * 5)/Engine.time_scale)
|
||||
else:
|
||||
gun.position = lerp(gun.position, weapon_start_pos,delta * 10)
|
||||
gun.position = lerp(gun.position, weapon_start_pos,(delta * 100)/Engine.time_scale)
|
||||
|
||||
func grab_moveable(body):
|
||||
holster_gun(true)
|
||||
|
||||
@@ -64,6 +64,7 @@ var cycle_count
|
||||
@onready var level_control = get_tree().current_scene
|
||||
@onready var ammo_current
|
||||
|
||||
var chamber_rot_amt = 0
|
||||
var casing_array = []
|
||||
var casing_spawn_array = []
|
||||
var bullet_array = []
|
||||
@@ -97,7 +98,9 @@ func _ready():
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
var rot_amount = chamber_rot_amt * delta * 10
|
||||
chamber.rotate_object_local(Vector3(0,-1,0),deg_to_rad(rot_amount))
|
||||
chamber_rot_amt -= rot_amount
|
||||
|
||||
|
||||
func reload_finished():
|
||||
@@ -159,7 +162,7 @@ func fire(delta):
|
||||
get_tree().get_root().add_child(instance_bullet)
|
||||
player.recoil.add_recoil(Vector3(0,recoil_amount.y,recoil_amount.z),10,recoil_speed_change)
|
||||
player.recoil.add_gun_recoil(recoil_amount.x)
|
||||
chamber.rotate_object_local(Vector3(0,-1,0),deg_to_rad(60))
|
||||
chamber_rot_amt += 60
|
||||
Input.start_joy_vibration(0,.5,.9,.2)
|
||||
|
||||
func reload():
|
||||
|
||||
Reference in New Issue
Block a user