started work on gun switching, need to iron out kinks and set up weapon management script
This commit is contained in:
@@ -317,6 +317,7 @@ _data = {
|
||||
}
|
||||
|
||||
[node name="mac10" node_paths=PackedStringArray("flare_light", "anim_player", "barrel_raycast", "casing_ejector", "mag_ejector", "audio_fire", "audio_empty", "audio_reload") instance=ExtResource("1_nb4p5")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.247, -0.222)
|
||||
script = ExtResource("2_6i1l4")
|
||||
max_ammo = 30
|
||||
random_spread_amt = 1.5
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=18 format=3 uid="uid://dslxb3psx30vp"]
|
||||
[gd_scene load_steps=17 format=3 uid="uid://dslxb3psx30vp"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://svrb3n31mkag" path="res://assets/Models/gun.blend" id="1_frekg"]
|
||||
[ext_resource type="Script" path="res://scripts/gun.gd" id="2_63tea"]
|
||||
@@ -199,9 +199,6 @@ _data = {
|
||||
"sprint": SubResource("Animation_tikvk")
|
||||
}
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_spb41"]
|
||||
size = Vector3(0.136963, 0.230713, 1.03125)
|
||||
|
||||
[node name="Pistol" node_paths=PackedStringArray("flare_light", "anim_player", "barrel_raycast", "casing_ejector", "mag_ejector", "audio_fire", "audio_empty", "audio_reload") instance=ExtResource("1_frekg")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0145504, -0.0460228)
|
||||
script = ExtResource("2_63tea")
|
||||
@@ -245,15 +242,7 @@ target_position = Vector3(0, 0, -1)
|
||||
transform = Transform3D(0.999999, -0.000519563, 0.000908768, 0.000519589, 1, -2.83433e-05, -0.000908754, 2.88053e-05, 1, 0.085, 0.187, 0)
|
||||
target_position = Vector3(1, 0, 0)
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="." index="4"]
|
||||
collision_layer = 2
|
||||
collision_mask = 2
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D" index="0"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.138702, -0.356865)
|
||||
shape = SubResource("BoxShape3D_spb41")
|
||||
|
||||
[node name="Audio" type="Node3D" parent="." index="5"]
|
||||
[node name="Audio" type="Node3D" parent="." index="4"]
|
||||
|
||||
[node name="Fire" type="AudioStreamPlayer3D" parent="Audio" index="0"]
|
||||
stream = ExtResource("8_jtjwm")
|
||||
@@ -269,7 +258,7 @@ stream = ExtResource("10_xn8pu")
|
||||
volume_db = 3.0
|
||||
bus = &"SFX"
|
||||
|
||||
[node name="SpotLight3D" type="SpotLight3D" parent="." index="6"]
|
||||
[node name="SpotLight3D" type="SpotLight3D" parent="." index="5"]
|
||||
transform = Transform3D(-6.79394e-06, 0, 1.87678, 0, 1.87678, 0, -1.87677, 0, -6.79392e-06, -1.63231, 0, 5.90892e-06)
|
||||
light_color = Color(0.965385, 0.844179, 0.572893, 1)
|
||||
light_energy = 0.0
|
||||
|
||||
@@ -28,7 +28,7 @@ shadow_color = Color(0, 0, 0, 1)
|
||||
size = Vector3(3, 3, 3)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_gnkxs"]
|
||||
size = Vector3(10, 3, 10)
|
||||
size = Vector3(10, 5.48804, 10)
|
||||
|
||||
[node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("weapon_holder", "gun") groups=["player"]]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.11359, 0)
|
||||
@@ -125,6 +125,7 @@ collision_layer = 0
|
||||
collision_mask = 4
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="pick_up_magnet"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.713223, -3.23375)
|
||||
shape = SubResource("BoxShape3D_gnkxs")
|
||||
|
||||
[node name="Audio" type="Node" parent="."]
|
||||
|
||||
@@ -86,6 +86,16 @@ inspect={
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":73,"key_label":0,"unicode":105,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
scroll_up={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":4,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
scroll_down={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":5,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[rendering]
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
[gd_scene load_steps=46 format=3 uid="uid://dyop6vk3rgkkb"]
|
||||
[gd_scene load_steps=49 format=3 uid="uid://dyop6vk3rgkkb"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/WeaponManager.gd" id="1_orhgl"]
|
||||
[ext_resource type="Texture2D" uid="uid://dqs06ic3vjtwk" path="res://assets/Models/asphalt1.albedo.jpg" id="1_w4rag"]
|
||||
[ext_resource type="PackedScene" uid="uid://drwae3loscbw7" path="res://assets/player.tscn" id="2_f87c2"]
|
||||
[ext_resource type="PackedScene" uid="uid://brl0bsqjl5dg3" path="res://assets/mac_10.tscn" id="2_q7f7y"]
|
||||
[ext_resource type="PackedScene" uid="uid://d1j6ktsmxfq6e" path="res://assets/spider.tscn" id="3_cvvjo"]
|
||||
[ext_resource type="PackedScene" uid="uid://dslxb3psx30vp" path="res://assets/pistol1.tscn" id="3_k8htc"]
|
||||
[ext_resource type="PackedScene" uid="uid://20csd6dmwj4y" path="res://assets/jump_platform.tscn" id="4_8nxyr"]
|
||||
[ext_resource type="PackedScene" uid="uid://dws2vwfxubqvb" path="res://assets/cannon.tscn" id="5_28rul"]
|
||||
[ext_resource type="PackedScene" uid="uid://bpkmyd3wvqi5p" path="res://assets/boombox.tscn" id="6_xrg7k"]
|
||||
@@ -402,7 +405,10 @@ _data = {
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_82n8k"]
|
||||
size = Vector3(16.265, 5.07275, 15.3267)
|
||||
|
||||
[node name="restaurant1" type="Node3D"]
|
||||
[node name="Test Level 2" type="Node3D"]
|
||||
script = ExtResource("1_orhgl")
|
||||
gun_1 = ExtResource("2_q7f7y")
|
||||
gun_2 = ExtResource("3_k8htc")
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("2_f87c2")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.0295, 1.4435, 21.1166)
|
||||
|
||||
File diff suppressed because one or more lines are too long
13
scripts/WeaponManager.gd
Normal file
13
scripts/WeaponManager.gd
Normal file
@@ -0,0 +1,13 @@
|
||||
extends Node3D
|
||||
|
||||
@export var gun_1 : Resource
|
||||
@export var gun_2 : Resource
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
@@ -49,7 +49,7 @@ func _process(delta):
|
||||
ray.enabled = false
|
||||
|
||||
#bullethole effect
|
||||
instance_bullethole = gun.bullethole.instantiate()
|
||||
#instance_bullethole = gun.bullethole.instantiate()
|
||||
ray.get_collider().add_child(instance_bullethole)
|
||||
instance_bullethole.global_transform.origin = ray.get_collision_point()
|
||||
instance_bullethole.look_at(ray.get_collision_point() + ray.get_collision_normal(), Vector3.UP)
|
||||
|
||||
@@ -94,6 +94,7 @@ func shoot(player,delta):
|
||||
instance_bullet.bullet_speed = bullet_speed
|
||||
instance_bullet.bullet_drop = bullet_drop
|
||||
instance_bullet.random_spread_amt = random_spread_amt
|
||||
instance_bullet.instance_bullethole = bullethole.instantiate()
|
||||
instance_bullet.gun = self
|
||||
get_tree().get_root().add_child(instance_bullet)
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ var start_sensitivity
|
||||
@export var gun : Node
|
||||
|
||||
@onready var gun_ray = $Head/Camera3D/GunRay
|
||||
@onready var level_control = $".."
|
||||
|
||||
@onready var bullet_ray = $Head/Camera3D/BulletRay
|
||||
var instance_bullet
|
||||
@@ -64,16 +65,18 @@ var pickupmsg
|
||||
@onready var world_environment = $"../WorldEnvironment"
|
||||
@onready var pickup_sound = $Audio/PickupSound
|
||||
@onready var ear_wind = $Audio/EarWind
|
||||
@onready var weapon_spawner = $Head/Camera3D/WeaponHolder/WeaponSpawner
|
||||
|
||||
|
||||
func _ready():
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
start_sensitivity = SENSITIVITY
|
||||
|
||||
#Set up gun variables
|
||||
def_weapon_holder_pos = weapon_holder.position
|
||||
ammo = gun.max_ammo
|
||||
ammo_reserve = gun.max_ammo * gun.start_mags
|
||||
bullet_damage = gun.bullet_damage
|
||||
start_sensitivity = SENSITIVITY
|
||||
gun_fire_pitch_starting = gun.audio_fire.pitch_scale
|
||||
|
||||
#turn off audio if unchecked in player
|
||||
@@ -181,6 +184,31 @@ func _physics_process(delta):
|
||||
gun.position = lerp(gun.position, gun.start_position,delta*7)
|
||||
gun_folded = false
|
||||
|
||||
#Weapon Swap Up
|
||||
if Input.is_action_just_pressed("scroll_up"):
|
||||
gun.queue_free()
|
||||
var instance_gun = level_control.gun_2.instantiate()
|
||||
instance_gun.global_transform.origin = weapon_spawner.position
|
||||
gun = instance_gun
|
||||
def_weapon_holder_pos = weapon_holder.position
|
||||
ammo = gun.max_ammo
|
||||
ammo_reserve = gun.max_ammo * gun.start_mags
|
||||
bullet_damage = gun.bullet_damage
|
||||
gun_fire_pitch_starting = gun.audio_fire.pitch_scale
|
||||
weapon_holder.add_child(instance_gun)
|
||||
#Weapon Swap Down
|
||||
if Input.is_action_just_pressed("scroll_down"):
|
||||
gun.queue_free()
|
||||
var instance_gun = level_control.gun_1.instantiate()
|
||||
instance_gun.global_transform.origin = weapon_spawner.position
|
||||
gun = instance_gun
|
||||
def_weapon_holder_pos = weapon_holder.position
|
||||
ammo = gun.max_ammo
|
||||
ammo_reserve = gun.max_ammo * gun.start_mags
|
||||
bullet_damage = gun.bullet_damage
|
||||
gun_fire_pitch_starting = gun.audio_fire.pitch_scale
|
||||
weapon_holder.add_child(instance_gun)
|
||||
|
||||
move_and_slide()
|
||||
weapon_tilt(input_dir.x, delta)
|
||||
weapon_sway(delta)
|
||||
@@ -226,7 +254,8 @@ func _on_pick_up_detection_body_entered(body):
|
||||
|
||||
func _on_pick_up_magnet_body_entered(body):
|
||||
if body.is_in_group("pickup"):
|
||||
print("pickup")
|
||||
var pickup_direction = self.global_position - body.global_position
|
||||
body.linear_velocity += pickup_direction * 5
|
||||
|
||||
func weapon_tilt(input_x, delta):
|
||||
if weapon_holder:
|
||||
|
||||
Reference in New Issue
Block a user