WIP: Currently I'm not sure how to do it

This commit is contained in:
Nikolai Rodionov 2025-01-26 14:39:11 +01:00
parent 7da4a3d6bb
commit adce112be9
Signed by: allanger
GPG Key ID: 09F8B434D0FDD99B
7 changed files with 54 additions and 8 deletions

View File

@ -1,8 +1,11 @@
extends Node3D
var owner_placeholder: CharacterBody3D = null
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
print("ready")
owner_placeholder = _get_owner()
pass # Replace with function body.
@ -12,5 +15,12 @@ func _process(delta: float) -> void:
func _on_head_collision_body_part_hit(dam: Variant) -> void:
print("head is hit")
print("head is hit" + str(dam))
owner_placeholder.take_damage(dam)
pass # Replace with function body.
func _get_owner() -> CharacterBody3D:
var owner_placeholder := find_parent("CharacterPlaceholder")
return owner_placeholder

View File

@ -4,10 +4,10 @@ extends Area3D
signal body_part_hit(dam)
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=9 format=3 uid="uid://b10lpwfjgxds4"]
[gd_scene load_steps=10 format=3 uid="uid://b10lpwfjgxds4"]
[ext_resource type="Script" path="res://scripts/player/player_input_controller.gd" id="1_q75ai"]
[ext_resource type="Texture2D" uid="uid://oopj5mj1vdp0" path="res://assets/crosshairs/crosshair_default.png" id="2_lsd7c"]
@ -72,6 +72,9 @@ _data = {
"shooting": SubResource("Animation_ah507")
}
[sub_resource type="LabelSettings" id="LabelSettings_toaij"]
font_size = 70
[node name="CharacterPlaceholder" type="CharacterBody3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.799455, 0)
collision_layer = 9
@ -96,6 +99,7 @@ transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0,
[node name="AimRay" type="RayCast3D" parent="FirstPersonCameraMount/BulletStartingPoint"]
target_position = Vector3(0, 0, 1000)
hit_from_inside = true
collide_with_areas = true
[node name="GunMount" type="Node3D" parent="FirstPersonCameraMount"]
@ -130,5 +134,16 @@ grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("2_lsd7c")
[node name="HealthIndicator" type="Label" parent="FirstPersonCameraMount/HUD"]
layout_mode = 1
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_top = -23.0
offset_right = 40.0
grow_vertical = 0
text = "100"
label_settings = SubResource("LabelSettings_toaij")
[node name="ModelMount" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.790262, 0)

View File

@ -1,10 +1,11 @@
[gd_scene load_steps=81 format=4 uid="uid://c1v6kb00y77ij"]
[gd_scene load_steps=82 format=4 uid="uid://c1v6kb00y77ij"]
[ext_resource type="Script" path="res://scenes/maps/el_test.gd" id="1_d5e7i"]
[ext_resource type="Texture2D" uid="uid://60qg81svnxfd" path="res://assets/models/maps/el_test_Image_0.png" id="2_o6seo"]
[ext_resource type="Texture2D" uid="uid://blj7gvw33u8qd" path="res://assets/models/maps/el_test_Image_1.png" id="3_7c4ej"]
[ext_resource type="Texture2D" uid="uid://to0g5ktan37x" path="res://assets/models/maps/el_test_Image_2.png" id="4_03be1"]
[ext_resource type="Script" path="res://scenes/maps/csg_box_3d.gd" id="5_3oqpw"]
[ext_resource type="PackedScene" uid="uid://1txob6jskn5s" path="res://scenes/characters/blue/dummy.tscn" id="6_4krea"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_1on1b"]
resource_name = "Orange_Playground_Base_Color"
@ -1193,3 +1194,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.72051, 0)
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_ru18i")
camera_attributes = SubResource("CameraAttributesPractical_vtlae")
[node name="Dummy" parent="." instance=ExtResource("6_4krea")]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 3.73853, 1.28053, -2.71689)

View File

@ -1,5 +1,6 @@
extends MeshInstance3D
var alpha = 1.0
func init(pos1, pos2):
var draw_mesh := ImmediateMesh.new()
mesh = draw_mesh
@ -10,12 +11,15 @@ func init(pos1, pos2):
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
var dup_material = material_override.duplicate()
material_override = dup_material
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
alpha -= delta * 3.5
material_override.albedo_color.a = alpha
func _on_timer_timeout() -> void:

View File

@ -3,9 +3,11 @@
[ext_resource type="Script" path="res://scenes/weapon/misc/bullet_trail_generic.gd" id="1_k8eg1"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ybqvs"]
albedo_color = Color(0.934388, 0.967243, 0.955863, 1)
emission = Color(1, 1, 1, 1)
emission_energy_multiplier = 2.7
transparency = 1
albedo_color = Color(0.917767, 0.596302, 0, 1)
emission_enabled = true
emission = Color(0.454139, 0.861507, 0, 1)
emission_energy_multiplier = 4.0
[node name="BulletTrailGeneric" type="MeshInstance3D"]
material_override = SubResource("StandardMaterial3D_ybqvs")

View File

@ -130,6 +130,12 @@ func _rotate_camera(sens_mod: float = 1.0) -> void:
rotation.y -= look_dir.x * camera_sens * sens_mod
first_view_camera_mount.rotation.x = clamp(first_view_camera_mount.rotation.x - look_dir.y * camera_sens * sens_mod, -1.5, 1.5)
@onready var health_indicator = $FirstPersonCameraMount/HUD/HealthIndicator
func _process(delta: float) -> void:
health_indicator.text = str(health)
if health == 0:
queue_free()
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
@ -169,6 +175,8 @@ func _shoot():
var collider := aim_ray.get_collider()
if collider != null and collider.is_in_group("target"):
aim_ray.get_collider().take_damage()
if collider != null and collider.is_in_group("body"):
collider.hit()
var root := get_tree().get_root()
gun_with_hands.shoot()
@ -198,3 +206,6 @@ func _hit_scan_collision(collision_point):
func _hit_scan_damage(Collider):
#if Collider.is_in_group("target") and Collider.has_method("take_damage"):
print("damaged")
func take_damage(dam: int):
health =- dam