tweaked bullet and pick up method

This commit is contained in:
Derek
2024-11-04 23:04:56 -06:00
parent 818b25417a
commit 3002c6e2db
9 changed files with 40 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
[gd_scene load_steps=5 format=3 uid="uid://5jhwtkdggfle"]
[ext_resource type="Script" path="res://assets/casing_2.gd" id="1_dxvh8"]
[ext_resource type="Script" path="res://assets/casing.gd" id="1_dxvh8"]
[ext_resource type="PackedScene" uid="uid://bv0sfqdgwa85p" path="res://assets/Models/casing.blend" id="2_ba08p"]
[ext_resource type="AudioStream" uid="uid://c76b5enfeodn5" path="res://assets/Audio/coin-drop-SBA-300024590.wav" id="3_2vc1o"]

View File

@@ -50,6 +50,8 @@ points = PackedVector3Array(0.202827, -0.297797, 0.00403334, -0.192761, -0.35888
collision_layer = 32
collision_mask = 125
continuous_cd = true
contact_monitor = true
max_contacts_reported = 1
script = ExtResource("1_sfpqr")
broken_object = ExtResource("2_e3uhf")
@@ -59,3 +61,5 @@ skeleton = NodePath("")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("ConvexPolygonShape3D_cymse")
[connection signal="body_shape_entered" from="." to="." method="_on_body_shape_entered"]

View File

@@ -1,7 +1,7 @@
[gd_scene load_steps=5 format=3 uid="uid://c1gdehrsytlkk"]
[ext_resource type="PackedScene" uid="uid://bv0sfqdgwa85p" path="res://assets/Models/casing.blend" id="1_8ox1t"]
[ext_resource type="Script" path="res://assets/casing_2.gd" id="1_34yke"]
[ext_resource type="Script" path="res://assets/casing.gd" id="1_34yke"]
[ext_resource type="AudioStream" uid="uid://c76b5enfeodn5" path="res://assets/Audio/coin-drop-SBA-300024590.wav" id="3_op3tv"]
[sub_resource type="CylinderShape3D" id="CylinderShape3D_ejwa0"]

View File

@@ -194,6 +194,10 @@ offset_bottom = 2160.0
[node name="MoveableHolder" type="Node3D" parent="Head"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.287198, -2.1034)
[node name="StandCheck" type="RayCast3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.989648, 0)
collision_mask = 33
[node name="pick_up_detection" type="Area3D" parent="."]
collision_layer = 0
collision_mask = 16

View File

@@ -2,6 +2,7 @@ extends RigidBody3D
@export var broken_object : Resource
var break_on_land : bool = false
# Called when the node enters the scene tree for the first time.
func _ready():
@@ -10,7 +11,8 @@ func _ready():
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
if linear_velocity.length() >= 10:
break_on_land = true
func breaking(current_velocity):
var spawn_broken = broken_object.instantiate()
@@ -23,3 +25,8 @@ func breaking(current_velocity):
piece.linear_velocity += current_velocity
get_tree().get_root().add_child(spawn_broken)
queue_free()
func _on_body_shape_entered(body_rid: RID, body: Node, body_shape_index: int, local_shape_index: int) -> void:
if break_on_land:
breaking(linear_velocity)

View File

@@ -24,7 +24,6 @@ func _ready():
visible = false
linear_velocity += transform.basis * Vector3(0, 0, -bullet_speed)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta):
@@ -40,6 +39,12 @@ func _physics_process(delta):
mesh.visible = false
ray.enabled = false
if ray.get_collider().is_in_group("enemy_target"):
hit_indicator.play()
enemy_particles.emitting = true
SignalBus.emit_signal("enemy_hit")
ray.get_collider().hit(bullet_damage)
#bullethole effect
ray.get_collider().add_child(instance_bullethole)
instance_bullethole.global_transform.origin = ray.get_collision_point()
@@ -59,10 +64,5 @@ func _physics_process(delta):
var current_velocity = transform.basis * Vector3(0,0,-1 * bullet_force_mod)
ray.get_collider().breaking(current_velocity)
if ray.get_collider().is_in_group("enemy_target"):
hit_indicator.play()
enemy_particles.emitting = true
ray.get_collider().hit(bullet_damage)
await get_tree().create_timer(1.0).timeout
queue_free()

View File

@@ -1,9 +1,16 @@
extends TextureRect
var viewportWidth
var viewportHeight
var start_size
var changed_size
# Called when the node enters the scene tree for the first time.
func _ready():
pass
viewportWidth = get_viewport().size.x
viewportHeight = get_viewport().size.y
start_size = Vector2(size.x, size.y)
changed_size = start_size
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):

View File

@@ -3,7 +3,7 @@ extends CharacterBody3D
const WALK_TRANSITION_SPEED = 8
const MAX_AIR_DASH = 1
const FLASHLIGHT_BRIGHTNESS = 30
const KICK_AMOUNT = 10
const KICK_AMOUNT = 20
const LAND_CAMERA_TILT : Vector3 = Vector3(-1,0,0)
const WALK_SPEED = 12.0
const SPRINT_SPEED = 15.0
@@ -45,9 +45,6 @@ var start_sensitivity
@export var BASE_FOV : float = 80
@export var FOV_CHANGE = 1.5
#@export_group("Gun") DELETE IF DOESNT CAUSE ISSUES
#@export
var gun : Node
@onready var dead_player : Resource = load("res://assets/dead_cam.tscn")
@onready var pause_menu: Control = $Head/Recoil/Camera3D/PauseMenu
@@ -111,6 +108,7 @@ var pickupmsg
@onready var weapon_pickup_audio: AudioStreamPlayer = $Audio/WeaponPickup
@onready var crt_filter: ColorRect = $Head/Recoil/Camera3D/crtFilter
@onready var moveable_holder: Node3D = $Head/MoveableHolder
@onready var stand_check: RayCast3D = $StandCheck
func _ready():
@@ -335,13 +333,15 @@ func _physics_process(delta):
if held_item != null:
var held_force_dir = moveable_holder.global_position - held_item.global_position
held_item.set_constant_force(held_force_dir * 30)
held_item.rotation = lerp(held_item.rotation, held_item_rotation, delta)
print("HELD ITEM ROTATION " + str(rad_to_deg(held_item_rotation.y)))
held_item.rotation = held_item_rotation #lerp(held_item.rotation, held_item_rotation, delta * 30)
#break when moved too far away
var distance_from_player = abs(self.global_position - held_item.global_position)
if distance_from_player.length() > 5:
release_moveable()
if stand_check.is_colliding():
if stand_check.get_collider() == held_item:
release_moveable()
#interact button
if Input.is_action_just_pressed("interact"):
@@ -451,7 +451,6 @@ func grab_moveable(body):
held_item_angular_damp_cache = body.angular_damp
held_item_gravity_cache = body.gravity_scale
held_item_mass_cache = body.mass
#change rigidbody settings
body.linear_damp = 5
body.angular_damp = 5