VERY rough test of replaying camera loc/rot
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
[gd_scene load_steps=12 format=4 uid="uid://neb8fxkrade0"]
|
||||
[gd_scene load_steps=13 format=4 uid="uid://neb8fxkrade0"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/bullet_cam.gd" id="1_uvdg3"]
|
||||
[ext_resource type="AudioStream" uid="uid://dqj4cx05f25jj" path="res://assets/Audio/punch-body-hard-SBA-300156881.wav" id="3_t6e3w"]
|
||||
|
||||
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_w2xv5"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_mfpbf"]
|
||||
resource_name = "bullet"
|
||||
transparency = 1
|
||||
@@ -83,7 +85,7 @@ radius = 0.055
|
||||
[node name="BulletCam" type="RigidBody3D"]
|
||||
top_level = true
|
||||
collision_layer = 128
|
||||
collision_mask = 225
|
||||
collision_mask = 233
|
||||
mass = 0.01
|
||||
center_of_mass_mode = 1
|
||||
continuous_cd = true
|
||||
@@ -96,6 +98,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.789394)
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1.35947)
|
||||
attributes = SubResource("CameraAttributesPractical_w2xv5")
|
||||
fov = 150.0
|
||||
|
||||
[node name="Cylinder" type="MeshInstance3D" parent="."]
|
||||
@@ -140,4 +143,14 @@ target_position = Vector3(0, 0, -2)
|
||||
collision_mask = 105
|
||||
collide_with_areas = true
|
||||
|
||||
[node name="cam_ray" type="RayCast3D" parent="."]
|
||||
target_position = Vector3(0, 0, -200)
|
||||
collision_mask = 105
|
||||
collide_with_areas = true
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
wait_time = 0.01
|
||||
autostart = true
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||
|
||||
@@ -580,7 +580,7 @@ attenuation_model = 1
|
||||
autoplay = true
|
||||
|
||||
[node name="Magnet_Timer" type="Timer" parent="."]
|
||||
wait_time = 0.5
|
||||
wait_time = 0.01
|
||||
one_shot = true
|
||||
autostart = true
|
||||
|
||||
|
||||
@@ -684,7 +684,7 @@ fov_zoom_amt = 15.0
|
||||
recoil_amount = Vector3(0.02, 0.05, 0.05)
|
||||
max_ammo = 20
|
||||
bullet_damage = 2
|
||||
bullet_speed = 1200
|
||||
bullet_speed = 600
|
||||
r_hand_location = NodePath("mac10/RHandLocation")
|
||||
l_hand_location = NodePath("mac10/mag/LHandLocation")
|
||||
flare_light = NodePath("mac10/flare")
|
||||
|
||||
884
assets/revolver2_pickup.tscn
Normal file
884
assets/revolver2_pickup.tscn
Normal file
File diff suppressed because one or more lines are too long
1537
assets/revolver_2.tscn
Normal file
1537
assets/revolver_2.tscn
Normal file
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=121 format=4 uid="uid://dyop6vk3rgkkb"]
|
||||
[gd_scene load_steps=123 format=4 uid="uid://dyop6vk3rgkkb"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/LevelManager.gd" id="1_orhgl"]
|
||||
[ext_resource type="Texture2D" uid="uid://dqs06ic3vjtwk" path="res://assets/Models/asphalt1.albedo.jpg" id="1_w4rag"]
|
||||
@@ -40,7 +40,9 @@
|
||||
[ext_resource type="Script" path="res://scripts/room_manager.gd" id="39_g18ck"]
|
||||
[ext_resource type="PackedScene" uid="uid://djr7vnr1hcx82" path="res://assets/spider2.tscn" id="40_a0e3y"]
|
||||
[ext_resource type="PackedScene" uid="uid://cucqbjb8bcha5" path="res://assets/blunderbuss_pickup.tscn" id="41_c48kk"]
|
||||
[ext_resource type="PackedScene" uid="uid://d4suhr3allsj" path="res://assets/revolver2_pickup.tscn" id="42_2cdbd"]
|
||||
[ext_resource type="PackedScene" uid="uid://dws4iro7820fc" path="res://assets/pistol1_pickup.tscn" id="42_mmvms"]
|
||||
[ext_resource type="PackedScene" uid="uid://bj1y0fbjtul4a" path="res://post_processing.tscn" id="43_82hec"]
|
||||
|
||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_nb6x7"]
|
||||
sky_top_color = Color(0.500562, 0.697334, 0.809889, 1)
|
||||
@@ -1162,6 +1164,7 @@ _data = {
|
||||
|
||||
[node name="Test Level 2" type="Node3D" node_paths=PackedStringArray("player")]
|
||||
script = ExtResource("1_orhgl")
|
||||
load_save = false
|
||||
player = NodePath("Player")
|
||||
start_health = 10
|
||||
gun_1 = ExtResource("2_6rjit")
|
||||
@@ -1600,3 +1603,9 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.73292, 5.31488, 1.53977)
|
||||
|
||||
[node name="pistol1_pickup" parent="." instance=ExtResource("42_mmvms")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.6973, 5.37926, -0.000322819)
|
||||
|
||||
[node name="pistol1_pickup2" parent="." instance=ExtResource("42_2cdbd")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.93409, 5.69926, 1.22332)
|
||||
|
||||
[node name="PostProcessing" parent="." instance=ExtResource("43_82hec")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8.35692, 7.15345, 5.33085)
|
||||
|
||||
@@ -20,6 +20,12 @@ var player_cam_FOV : float
|
||||
var opaque_color = Color(0.702, 0.557, 0.224)
|
||||
var transparent_color = Color(0.702, 0.557, 0.224, 0)
|
||||
|
||||
var record_id = 0
|
||||
|
||||
#replay path
|
||||
var bullet_path = {}
|
||||
var on_replay = false
|
||||
|
||||
@onready var level_control = get_tree().current_scene
|
||||
@onready var player = level_control.player
|
||||
@onready var mesh = $Cylinder
|
||||
@@ -30,15 +36,18 @@ var transparent_color = Color(0.702, 0.557, 0.224, 0)
|
||||
@onready var camera: Camera3D = $Camera3D
|
||||
@onready var camera_handle: Node3D = $CameraHandle
|
||||
@onready var bullet_material = mesh.get_surface_override_material(0)
|
||||
@onready var cam_ray: RayCast3D = $cam_ray
|
||||
|
||||
|
||||
const BULLET_CAM_FOV : float = 130
|
||||
const BULLET_SENSITIVITY : float = 1
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventMouseMotion and hold_cam_pos == null:
|
||||
var av_y = -event.relative.x * BULLET_SENSITIVITY
|
||||
var av_x = -event.relative.y * BULLET_SENSITIVITY
|
||||
angular_velocity += transform.basis * Vector3(av_x,av_y,0)
|
||||
if !on_replay:
|
||||
if event is InputEventMouseMotion and hold_cam_pos == null:
|
||||
var av_y = -event.relative.x * BULLET_SENSITIVITY
|
||||
var av_x = -event.relative.y * BULLET_SENSITIVITY
|
||||
angular_velocity += transform.basis * Vector3(av_x,av_y,0)
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
@@ -54,26 +63,33 @@ func _ready():
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _physics_process(delta):
|
||||
camera.fov = lerp(player_cam_FOV,BULLET_CAM_FOV, delta * 3000)
|
||||
camera.fov = lerp(player_cam_FOV,BULLET_CAM_FOV, (delta * 300)/Engine.time_scale)
|
||||
linear_velocity = transform.basis * Vector3(0, 0, -bullet_speed)
|
||||
|
||||
var distance_to_cam = camera.global_position.distance_to(camera_handle.global_position) / (distance_to_cam_start*2)
|
||||
bullet_material.albedo_color = lerp(transparent_color,opaque_color,distance_to_cam)
|
||||
|
||||
if hold_cam_pos != null:
|
||||
camera.global_position = hold_cam_pos
|
||||
else:
|
||||
camera.global_position = lerp(camera.global_position,camera_handle.global_position, delta * 300)
|
||||
#if hold_cam_pos != null:
|
||||
#camera.global_position = hold_cam_pos
|
||||
#else:
|
||||
camera.global_position = lerp(camera.global_position,camera_handle.global_position, delta * 300)
|
||||
|
||||
if ray.is_colliding() and hold_cam_pos == null:
|
||||
hold_cam_pos = camera.global_position
|
||||
Engine.time_scale = .005
|
||||
|
||||
|
||||
if Input.is_action_pressed("sprint"):
|
||||
Engine.time_scale = .05
|
||||
else:
|
||||
Engine.time_scale = .01
|
||||
|
||||
focus_on_target()
|
||||
|
||||
log_path(delta)
|
||||
|
||||
func _on_body_entered(body: Node) -> void:
|
||||
|
||||
if !body.is_in_group("player"):
|
||||
|
||||
print("BULLET PATH: ",bullet_path)
|
||||
|
||||
ray.enabled = false
|
||||
|
||||
if ray.is_colliding():
|
||||
@@ -96,11 +112,35 @@ func _on_body_entered(body: Node) -> void:
|
||||
body.breaking(current_velocity)
|
||||
despawn()
|
||||
|
||||
func focus_on_target():
|
||||
const BLUR_AMOUNT = .1
|
||||
camera.attributes.dof_blur_far_enabled = true
|
||||
camera.attributes.dof_blur_far_distance = camera.global_position.distance_to(cam_ray.get_collision_point()) + 5.0
|
||||
camera.attributes.dof_blur_near_enabled = true
|
||||
camera.attributes.dof_blur_amount = lerp(0.0,BLUR_AMOUNT,1.0 - Engine.time_scale)
|
||||
|
||||
func log_path(delta):
|
||||
var frame_info = {
|
||||
"global_position" : global_position,
|
||||
"global_rotation" : global_rotation,
|
||||
"delta" : delta
|
||||
}
|
||||
|
||||
bullet_path[record_id] = frame_info
|
||||
record_id += 1
|
||||
|
||||
func despawn():
|
||||
player.camera.current = true
|
||||
player.controlled_elsewhere = false
|
||||
player.gamespeed_controlled = false
|
||||
#visible = false
|
||||
#collision_shape.disabled = true
|
||||
#await get_tree().create_timer(1).timeout
|
||||
queue_free()
|
||||
var read_record = record_id - 1
|
||||
for i in bullet_path:
|
||||
if read_record > 1:
|
||||
camera.global_position = lerp(bullet_path[read_record]["global_position"],bullet_path[read_record-1]["global_position"],bullet_path[read_record]["delta"])
|
||||
await get_tree().create_timer(bullet_path[read_record]["delta"]).timeout
|
||||
read_record -= 1
|
||||
if read_record <= 0:
|
||||
player.camera.current = true
|
||||
player.controlled_elsewhere = false
|
||||
player.gamespeed_controlled = false
|
||||
##visible = false
|
||||
##collision_shape.disabled = true
|
||||
##await get_tree().create_timer(1).timeout
|
||||
queue_free()
|
||||
|
||||
@@ -717,7 +717,8 @@ func weapon_sway(delta):
|
||||
|
||||
func weapon_bob(vel : float, delta):
|
||||
if weapon_holder:
|
||||
weapon_holder.global_position.y += -clamp(velocity.y * .15,-1,1) * delta
|
||||
if gun != null and !ads and !gun.ads:
|
||||
weapon_holder.global_position.y += -clamp(velocity.y * .15,-1,1) * delta
|
||||
if vel > 2 and is_on_floor():
|
||||
var speed_adjust = speed/WALK_SPEED
|
||||
var bob_amount : float = 0.05
|
||||
|
||||
@@ -42,7 +42,15 @@ func breaking(bullet_velocity):
|
||||
|
||||
#pickup drop
|
||||
while number_of_drops > 0:
|
||||
var rand_item = level_control.pickup_spawn()
|
||||
|
||||
var pickup_spawn = level_control.item_pickup.instantiate()
|
||||
var item_stats = level_control.pickup_spawn(false)
|
||||
|
||||
##SET VARIABLES
|
||||
pickup_spawn.pickup_type = item_stats["pickup_type"]
|
||||
pickup_spawn.ammo_type = item_stats["ammo_type"]
|
||||
pickup_spawn.value = item_stats["value"]
|
||||
|
||||
var lv_x = randf_range(-MAX_LV,MAX_LV)
|
||||
var lv_y = randf_range(0,MAX_LV)
|
||||
var lv_z = randf_range(-MAX_LV,MAX_LV)
|
||||
@@ -51,11 +59,11 @@ func breaking(bullet_velocity):
|
||||
var av_z = randf_range(-MAX_AV,MAX_AV)
|
||||
|
||||
# Random Item Drop
|
||||
rand_item.position = self.global_position
|
||||
rand_item.transform.basis = self.global_transform.basis
|
||||
rand_item.linear_velocity += self.global_transform.basis * Vector3(lv_x,lv_y,lv_z)
|
||||
rand_item.angular_velocity += self.global_transform.basis * Vector3(av_x,av_y,av_z)
|
||||
get_tree().get_root().add_child(rand_item)
|
||||
pickup_spawn.position = self.global_position
|
||||
pickup_spawn.transform.basis = self.global_transform.basis
|
||||
pickup_spawn.linear_velocity += self.global_transform.basis * Vector3(lv_x,lv_y,lv_z)
|
||||
pickup_spawn.angular_velocity += self.global_transform.basis * Vector3(av_x,av_y,av_z)
|
||||
get_tree().get_root().add_child(pickup_spawn)
|
||||
number_of_drops -= 1
|
||||
|
||||
#animate dead
|
||||
|
||||
@@ -178,6 +178,7 @@ func spawn_casing():
|
||||
instance_casing.position = casing_ejector.global_position
|
||||
instance_casing.transform.basis = casing_ejector.global_transform.basis
|
||||
instance_casing.player_velocity = velocity * transform.basis
|
||||
get_tree().get_root().add_child(instance_casing)
|
||||
|
||||
func dying_throws():
|
||||
dying = true
|
||||
|
||||
Reference in New Issue
Block a user