FINALLY FIXED REVOLVER CHAMBER
This commit is contained in:
@@ -4,26 +4,26 @@ render_mode unshaded, blend_mix, depth_draw_never, depth_test_disabled;
|
|||||||
/*
|
/*
|
||||||
AUTHOR: Hannah "EMBYR" Crawford
|
AUTHOR: Hannah "EMBYR" Crawford
|
||||||
ENGINE_VERSION: 4.0.3
|
ENGINE_VERSION: 4.0.3
|
||||||
|
|
||||||
HOW TO USE:
|
HOW TO USE:
|
||||||
1. Create a MeshInstance3D node and place it in your scene.
|
1. Create a MeshInstance3D node and place it in your scene.
|
||||||
2. Set it's size to 2x2.
|
2. Set it's size to 2x2.
|
||||||
3. Enable the "Flip Faces" option.
|
3. Enable the "Flip Faces" option.
|
||||||
4. Create a new shader material with this shader.
|
4. Create a new shader material with this shader.
|
||||||
5. Assign the material to the MeshInstance3D
|
5. Assign the material to the MeshInstance3D
|
||||||
|
|
||||||
LIMITATIONS:
|
LIMITATIONS:
|
||||||
Does not work well with TAA enabled.
|
Does not work well with TAA enabled.
|
||||||
|
|
||||||
MOBILE_NOTES:
|
MOBILE_NOTES:
|
||||||
The mobile renderer does not have access to the normal_roughness texture
|
The mobile renderer does not have access to the normal_roughness texture
|
||||||
so we must rely on techniques to reconstruct this information from the
|
so we must rely on techniques to reconstruct this information from the
|
||||||
depth buffer.
|
depth buffer.
|
||||||
|
|
||||||
If you require support on mobile please uncomment the SUPPORT_MOBILE line
|
If you require support on mobile please uncomment the SUPPORT_MOBILE line
|
||||||
below. I have done my best to match the appearance between the two modes
|
below. I have done my best to match the appearance between the two modes
|
||||||
however, mobile does not take into account smooth-shaded faces.
|
however, mobile does not take into account smooth-shaded faces.
|
||||||
|
|
||||||
The high-quality reconstruction method used on mobile is rather heavy on
|
The high-quality reconstruction method used on mobile is rather heavy on
|
||||||
texture samples. If you would like to use the lower-quality recontruction
|
texture samples. If you would like to use the lower-quality recontruction
|
||||||
method for better performance, please uncomment the NAIVE_NORMAL_RECONSTRUCTION
|
method for better performance, please uncomment the NAIVE_NORMAL_RECONSTRUCTION
|
||||||
@@ -58,14 +58,14 @@ varying flat mat4 model_view_matrix;
|
|||||||
#endif// !SUPPORT_MOBILE
|
#endif// !SUPPORT_MOBILE
|
||||||
|
|
||||||
struct UVNeighbors {
|
struct UVNeighbors {
|
||||||
vec2 center;
|
vec2 center;
|
||||||
vec2 left; vec2 right; vec2 up; vec2 down;
|
vec2 left; vec2 right; vec2 up; vec2 down;
|
||||||
vec2 top_left; vec2 top_right; vec2 bottom_left; vec2 bottom_right;
|
vec2 top_left; vec2 top_right; vec2 bottom_left; vec2 bottom_right;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NeighborDepthSamples {
|
struct NeighborDepthSamples {
|
||||||
float c_d;
|
float c_d;
|
||||||
float l_d; float r_d; float u_d; float d_d;
|
float l_d; float r_d; float u_d; float d_d;
|
||||||
float tl_d; float tr_d; float bl_d; float br_d;
|
float tl_d; float tr_d; float bl_d; float br_d;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -124,16 +124,16 @@ float getGrazingAngleModulation(vec3 pixel_normal, vec3 view) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float detectEdgesDepth(NeighborDepthSamples depth_samples, vec3 pixel_normal, vec3 view) {
|
float detectEdgesDepth(NeighborDepthSamples depth_samples, vec3 pixel_normal, vec3 view) {
|
||||||
float n_total =
|
float n_total =
|
||||||
depth_samples.l_d +
|
depth_samples.l_d +
|
||||||
depth_samples.r_d +
|
depth_samples.r_d +
|
||||||
depth_samples.u_d +
|
depth_samples.u_d +
|
||||||
depth_samples.d_d +
|
depth_samples.d_d +
|
||||||
depth_samples.tl_d +
|
depth_samples.tl_d +
|
||||||
depth_samples.tr_d +
|
depth_samples.tr_d +
|
||||||
depth_samples.bl_d +
|
depth_samples.bl_d +
|
||||||
depth_samples.br_d;
|
depth_samples.br_d;
|
||||||
|
|
||||||
float t = depth_threshold * getGrazingAngleModulation(pixel_normal, view);
|
float t = depth_threshold * getGrazingAngleModulation(pixel_normal, view);
|
||||||
return step(t, n_total - (depth_samples.c_d * 8.0));
|
return step(t, n_total - (depth_samples.c_d * 8.0));
|
||||||
}
|
}
|
||||||
@@ -159,17 +159,17 @@ vec3 reconstructWorldNormal(sampler2D depth_tex, mat4 model_view, mat4 inv_proj,
|
|||||||
float b1 = texture(depth_tex, screen_uv - vec2(0,1) * e).r;
|
float b1 = texture(depth_tex, screen_uv - vec2(0,1) * e).r;
|
||||||
float t1 = texture(depth_tex, screen_uv + vec2(0,1) * e).r;
|
float t1 = texture(depth_tex, screen_uv + vec2(0,1) * e).r;
|
||||||
float t2 = texture(depth_tex, screen_uv + vec2(0,2) * e).r;
|
float t2 = texture(depth_tex, screen_uv + vec2(0,2) * e).r;
|
||||||
|
|
||||||
float dl = abs(l1 * l2 / (2.0 * l2 - l1) - c0);
|
float dl = abs(l1 * l2 / (2.0 * l2 - l1) - c0);
|
||||||
float dr = abs(r1 * r2 / (2.0 * r2 - r1) - c0);
|
float dr = abs(r1 * r2 / (2.0 * r2 - r1) - c0);
|
||||||
float db = abs(b1 * b2 / (2.0 * b2 - b1) - c0);
|
float db = abs(b1 * b2 / (2.0 * b2 - b1) - c0);
|
||||||
float dt = abs(t1 * t2 / (2.0 * t2 - t1) - c0);
|
float dt = abs(t1 * t2 / (2.0 * t2 - t1) - c0);
|
||||||
|
|
||||||
vec3 ce = reconstructWorldPosition(c0, model_view, inv_proj, screen_uv, world, inv_cam);
|
vec3 ce = reconstructWorldPosition(c0, model_view, inv_proj, screen_uv, world, inv_cam);
|
||||||
|
|
||||||
vec3 dpdx = (dl<dr) ? ce-reconstructWorldPosition(l1, model_view, inv_proj, screen_uv - vec2(1,0) * e, world, inv_cam) :
|
vec3 dpdx = (dl<dr) ? ce-reconstructWorldPosition(l1, model_view, inv_proj, screen_uv - vec2(1,0) * e, world, inv_cam) :
|
||||||
-ce+reconstructWorldPosition(r1, model_view, inv_proj, screen_uv + vec2(1,0) * e, world, inv_cam) ;
|
-ce+reconstructWorldPosition(r1, model_view, inv_proj, screen_uv + vec2(1,0) * e, world, inv_cam) ;
|
||||||
vec3 dpdy = (db<dt) ? ce-reconstructWorldPosition(b1, model_view, inv_proj, screen_uv - vec2(0,1) * e, world, inv_cam) :
|
vec3 dpdy = (db<dt) ? ce-reconstructWorldPosition(b1, model_view, inv_proj, screen_uv - vec2(0,1) * e, world, inv_cam) :
|
||||||
-ce+reconstructWorldPosition(t1, model_view, inv_proj, screen_uv + vec2(0,1) * e, world, inv_cam) ;
|
-ce+reconstructWorldPosition(t1, model_view, inv_proj, screen_uv + vec2(0,1) * e, world, inv_cam) ;
|
||||||
|
|
||||||
return normalize(cross(dpdx,dpdy));
|
return normalize(cross(dpdx,dpdy));
|
||||||
@@ -190,19 +190,19 @@ float detectEdgesNormalReconstructed(UVNeighbors uvs, sampler2D depth_tex, mat4
|
|||||||
vec3 n_tr = reconstructWorldNormal(depth_tex, model_view, inv_proj, uvs.top_right, world, inv_cam, viewport_size);
|
vec3 n_tr = reconstructWorldNormal(depth_tex, model_view, inv_proj, uvs.top_right, world, inv_cam, viewport_size);
|
||||||
vec3 n_bl = reconstructWorldNormal(depth_tex, model_view, inv_proj, uvs.bottom_left, world, inv_cam, viewport_size);
|
vec3 n_bl = reconstructWorldNormal(depth_tex, model_view, inv_proj, uvs.bottom_left, world, inv_cam, viewport_size);
|
||||||
vec3 n_br = reconstructWorldNormal(depth_tex, model_view, inv_proj, uvs.bottom_right, world, inv_cam, viewport_size);
|
vec3 n_br = reconstructWorldNormal(depth_tex, model_view, inv_proj, uvs.bottom_right, world, inv_cam, viewport_size);
|
||||||
|
|
||||||
vec3 normalFiniteDifference0 = n_tr - n_bl;
|
vec3 normalFiniteDifference0 = n_tr - n_bl;
|
||||||
vec3 normalFiniteDifference1 = n_tl - n_br;
|
vec3 normalFiniteDifference1 = n_tl - n_br;
|
||||||
vec3 normalFiniteDifference2 = n_l - n_r;
|
vec3 normalFiniteDifference2 = n_l - n_r;
|
||||||
vec3 normalFiniteDifference3 = n_u - n_d;
|
vec3 normalFiniteDifference3 = n_u - n_d;
|
||||||
|
|
||||||
float edgeNormal = sqrt(
|
float edgeNormal = sqrt(
|
||||||
dot(normalFiniteDifference0, normalFiniteDifference0) +
|
dot(normalFiniteDifference0, normalFiniteDifference0) +
|
||||||
dot(normalFiniteDifference1, normalFiniteDifference1) +
|
dot(normalFiniteDifference1, normalFiniteDifference1) +
|
||||||
dot(normalFiniteDifference2, normalFiniteDifference2) +
|
dot(normalFiniteDifference2, normalFiniteDifference2) +
|
||||||
dot(normalFiniteDifference3, normalFiniteDifference3)
|
dot(normalFiniteDifference3, normalFiniteDifference3)
|
||||||
) * 0.5;
|
) * 0.5;
|
||||||
|
|
||||||
return smoothstep(normal_threshold - normal_smoothing, normal_threshold + normal_smoothing, edgeNormal);
|
return smoothstep(normal_threshold - normal_smoothing, normal_threshold + normal_smoothing, edgeNormal);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -215,26 +215,26 @@ float detectEdgesNormal(UVNeighbors uvs, sampler2D normTex, vec3 camDirWorld){
|
|||||||
vec3 n_tr = texture(normTex, uvs.top_right).xyz;
|
vec3 n_tr = texture(normTex, uvs.top_right).xyz;
|
||||||
vec3 n_bl = texture(normTex, uvs.bottom_left).xyz;
|
vec3 n_bl = texture(normTex, uvs.bottom_left).xyz;
|
||||||
vec3 n_br = texture(normTex, uvs.bottom_right).xyz;
|
vec3 n_br = texture(normTex, uvs.bottom_right).xyz;
|
||||||
|
|
||||||
vec3 normalFiniteDifference0 = n_tr - n_bl;
|
vec3 normalFiniteDifference0 = n_tr - n_bl;
|
||||||
vec3 normalFiniteDifference1 = n_tl - n_br;
|
vec3 normalFiniteDifference1 = n_tl - n_br;
|
||||||
vec3 normalFiniteDifference2 = n_l - n_r;
|
vec3 normalFiniteDifference2 = n_l - n_r;
|
||||||
vec3 normalFiniteDifference3 = n_u - n_d;
|
vec3 normalFiniteDifference3 = n_u - n_d;
|
||||||
|
|
||||||
float edgeNormal = sqrt(
|
float edgeNormal = sqrt(
|
||||||
dot(normalFiniteDifference0, normalFiniteDifference0) +
|
dot(normalFiniteDifference0, normalFiniteDifference0) +
|
||||||
dot(normalFiniteDifference1, normalFiniteDifference1) +
|
dot(normalFiniteDifference1, normalFiniteDifference1) +
|
||||||
dot(normalFiniteDifference2, normalFiniteDifference2) +
|
dot(normalFiniteDifference2, normalFiniteDifference2) +
|
||||||
dot(normalFiniteDifference3, normalFiniteDifference3)
|
dot(normalFiniteDifference3, normalFiniteDifference3)
|
||||||
);
|
);
|
||||||
|
|
||||||
return smoothstep(normal_threshold - normal_smoothing, normal_threshold + normal_smoothing, edgeNormal);
|
return smoothstep(normal_threshold - normal_smoothing, normal_threshold + normal_smoothing, edgeNormal);
|
||||||
}
|
}
|
||||||
#endif//SUPPORT_MOBILE
|
#endif//SUPPORT_MOBILE
|
||||||
|
|
||||||
void vertex() {
|
void vertex() {
|
||||||
POSITION = vec4(VERTEX, 1.0);
|
POSITION = vec4(VERTEX, 1.0);
|
||||||
|
|
||||||
#ifdef SUPPORT_MOBILE
|
#ifdef SUPPORT_MOBILE
|
||||||
model_view_matrix = INV_VIEW_MATRIX * mat4(VIEW_MATRIX[0],VIEW_MATRIX[1],VIEW_MATRIX[2],VIEW_MATRIX[3]);;
|
model_view_matrix = INV_VIEW_MATRIX * mat4(VIEW_MATRIX[0],VIEW_MATRIX[1],VIEW_MATRIX[2],VIEW_MATRIX[3]);;
|
||||||
#endif
|
#endif
|
||||||
@@ -242,31 +242,31 @@ void vertex() {
|
|||||||
|
|
||||||
void fragment() {
|
void fragment() {
|
||||||
float aspect = float(VIEWPORT_SIZE.y) / float(VIEWPORT_SIZE.x);
|
float aspect = float(VIEWPORT_SIZE.y) / float(VIEWPORT_SIZE.x);
|
||||||
|
|
||||||
UVNeighbors n = getNeighbors(SCREEN_UV, max_thickness, aspect);
|
UVNeighbors n = getNeighbors(SCREEN_UV, max_thickness, aspect);
|
||||||
NeighborDepthSamples depth_samples = getLinearDepthSamples(n, DEPTH_TEXTURE, INV_PROJECTION_MATRIX);
|
NeighborDepthSamples depth_samples = getLinearDepthSamples(n, DEPTH_TEXTURE, INV_PROJECTION_MATRIX);
|
||||||
|
|
||||||
float min_d = getMinimumDepth(depth_samples);
|
float min_d = getMinimumDepth(depth_samples);
|
||||||
float thickness = clamp(remap(min_d, min_distance, max_distance, max_thickness, min_thickness), min_thickness, max_thickness);
|
float thickness = clamp(remap(min_d, min_distance, max_distance, max_thickness, min_thickness), min_thickness, max_thickness);
|
||||||
float fade_a = clamp(remap(min_d, min_distance, max_distance, 1.0, 0.0), 0.0, 1.0);
|
float fade_a = clamp(remap(min_d, min_distance, max_distance, 1.0, 0.0), 0.0, 1.0);
|
||||||
|
|
||||||
n = getNeighbors(SCREEN_UV, thickness, aspect);
|
n = getNeighbors(SCREEN_UV, thickness, aspect);
|
||||||
depth_samples = getLinearDepthSamples(n, DEPTH_TEXTURE, INV_PROJECTION_MATRIX);
|
depth_samples = getLinearDepthSamples(n, DEPTH_TEXTURE, INV_PROJECTION_MATRIX);
|
||||||
|
|
||||||
#ifndef SUPPORT_MOBILE
|
#ifndef SUPPORT_MOBILE
|
||||||
vec3 pixel_normal = texture(NORMR_TEXTURE, SCREEN_UV).xyz;
|
vec3 pixel_normal = texture(NORMR_TEXTURE, SCREEN_UV).xyz;
|
||||||
#else
|
#else
|
||||||
vec3 pixel_normal = reconstructWorldNormal(DEPTH_TEXTURE, model_view_matrix, INV_PROJECTION_MATRIX, SCREEN_UV, MODEL_MATRIX, INV_VIEW_MATRIX, VIEWPORT_SIZE.xy);
|
vec3 pixel_normal = reconstructWorldNormal(DEPTH_TEXTURE, model_view_matrix, INV_PROJECTION_MATRIX, SCREEN_UV, MODEL_MATRIX, INV_VIEW_MATRIX, VIEWPORT_SIZE.xy);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float depthEdges = detectEdgesDepth(depth_samples, pixel_normal, VIEW);
|
float depthEdges = detectEdgesDepth(depth_samples, pixel_normal, VIEW);
|
||||||
|
|
||||||
#ifndef SUPPORT_MOBILE
|
#ifndef SUPPORT_MOBILE
|
||||||
float normEdges = min(detectEdgesNormal(n, NORMR_TEXTURE, CAMERA_DIRECTION_WORLD), 1.0);
|
float normEdges = min(detectEdgesNormal(n, NORMR_TEXTURE, CAMERA_DIRECTION_WORLD), 1.0);
|
||||||
#else
|
#else
|
||||||
float normEdges = min(detectEdgesNormalReconstructed(n, DEPTH_TEXTURE, model_view_matrix, INV_PROJECTION_MATRIX, SCREEN_UV, MODEL_MATRIX, INV_VIEW_MATRIX, VIEWPORT_SIZE.xy), 1.0);
|
float normEdges = min(detectEdgesNormalReconstructed(n, DEPTH_TEXTURE, model_view_matrix, INV_PROJECTION_MATRIX, SCREEN_UV, MODEL_MATRIX, INV_VIEW_MATRIX, VIEWPORT_SIZE.xy), 1.0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ALBEDO.rgb = outlineColor.rgb;
|
ALBEDO.rgb = outlineColor.rgb;
|
||||||
ALPHA = max(depthEdges, normEdges) * outlineColor.a * fade_a;
|
ALPHA = max(depthEdges, normEdges) * outlineColor.a * fade_a;
|
||||||
}
|
}
|
||||||
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")
|
audio_reload = NodePath("Audio/Reload")
|
||||||
|
|
||||||
[node name="mac10" parent="." index="0"]
|
[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
|
cast_shadow = 0
|
||||||
lod_bias = 10.0
|
lod_bias = 10.0
|
||||||
mesh = SubResource("ArrayMesh_pcg38")
|
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)
|
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)
|
gun.position = lerp(gun.position,ADS_POS,delta * 10 / Engine.time_scale)
|
||||||
else:
|
else:
|
||||||
gun.position = lerp(gun.position, weapon_start_pos,delta * 2)
|
weapon_holder.rotation = lerp(weapon_holder.rotation,Vector3(0,0,0),(delta * 10)/Engine.time_scale)
|
||||||
camera.fov = lerp(camera.fov,BASE_FOV - float(gun.fov_zoom_amt),(delta * 4)/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:
|
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):
|
func grab_moveable(body):
|
||||||
holster_gun(true)
|
holster_gun(true)
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ var cycle_count
|
|||||||
@onready var level_control = get_tree().current_scene
|
@onready var level_control = get_tree().current_scene
|
||||||
@onready var ammo_current
|
@onready var ammo_current
|
||||||
|
|
||||||
|
var chamber_rot_amt = 0
|
||||||
var casing_array = []
|
var casing_array = []
|
||||||
var casing_spawn_array = []
|
var casing_spawn_array = []
|
||||||
var bullet_array = []
|
var bullet_array = []
|
||||||
@@ -97,7 +98,9 @@ func _ready():
|
|||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta):
|
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():
|
func reload_finished():
|
||||||
@@ -147,7 +150,7 @@ func fire(delta):
|
|||||||
if player.gun_folded == false:
|
if player.gun_folded == false:
|
||||||
instance_bullet.transform.basis = player.bullet_ray.global_transform.basis
|
instance_bullet.transform.basis = player.bullet_ray.global_transform.basis
|
||||||
else:
|
else:
|
||||||
instance_bullet.transform.basis = barrel_raycast.global_transform.basis
|
instance_bullet.transform.basis = barrel_raycast.global_transform.basis
|
||||||
instance_bullet.bullet_speed = bullet_speed
|
instance_bullet.bullet_speed = bullet_speed
|
||||||
instance_bullet.bullet_drop = bullet_drop
|
instance_bullet.bullet_drop = bullet_drop
|
||||||
instance_bullet.bullet_damage = bullet_damage
|
instance_bullet.bullet_damage = bullet_damage
|
||||||
@@ -159,7 +162,7 @@ func fire(delta):
|
|||||||
get_tree().get_root().add_child(instance_bullet)
|
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_recoil(Vector3(0,recoil_amount.y,recoil_amount.z),10,recoil_speed_change)
|
||||||
player.recoil.add_gun_recoil(recoil_amount.x)
|
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)
|
Input.start_joy_vibration(0,.5,.9,.2)
|
||||||
|
|
||||||
func reload():
|
func reload():
|
||||||
|
|||||||
Reference in New Issue
Block a user