This commit is contained in:
Victor Turgeon 2022-10-11 21:21:27 -04:00
parent 4973e22d23
commit d31b299251
15 changed files with 261 additions and 24 deletions

View File

@ -83,9 +83,10 @@ func _physics_process(delta):
if Input.is_action_just_pressed("crouch"): if Input.is_action_just_pressed("crouch"):
head.translate(Vector3.DOWN) head.translate(Vector3.DOWN)
speed = 20
if Input.is_action_just_released("crouch"): if Input.is_action_just_released("crouch"):
head.translate(Vector3.UP) head.translate(Vector3.UP)
isStep = false speed = 40
if Input.is_action_pressed("move_forward"): if Input.is_action_pressed("move_forward"):
direction -= transform.basis.z direction -= transform.basis.z
@ -113,14 +114,16 @@ func _physics_process(delta):
else: else:
isSlap = false; isSlap = false;
if isSlap: if isSlap:
if slap >= slapkill: if slap >= slapkill:
AudioMegaSlap.play() AudioMegaSlap.play()
else: else:
isSlap = false;
AudioSlap.play() AudioSlap.play()
isSlap = false;
hitbox.monitorable = true hitbox.monitorable = true
hitbox.slap_level = slap hitbox.slap_level = slap
hitbox.slap_kill = slapkill
hitbox.slap_vector = point_to.get_global_transform().origin - camera.get_global_transform().origin hitbox.slap_vector = point_to.get_global_transform().origin - camera.get_global_transform().origin
if (chargeSlap): if (chargeSlap):

View File

@ -21,7 +21,7 @@ height = 3.0
[sub_resource type="CylinderShape" id=3] [sub_resource type="CylinderShape" id=3]
[sub_resource type="BoxShape" id=7] [sub_resource type="BoxShape" id=7]
extents = Vector3( 0.797679, 1, 1 ) extents = Vector3( 0.983522, 2, 1.55035 )
[sub_resource type="SpatialMaterial" id=4] [sub_resource type="SpatialMaterial" id=4]
albedo_texture = ExtResource( 3 ) albedo_texture = ExtResource( 3 )
@ -109,16 +109,17 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.84218, 0 )
[node name="Camera" type="Camera" parent="Head"] [node name="Camera" type="Camera" parent="Head"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0154071, 0.355, -0.246618 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0154071, 0.355, -0.246618 )
fov = 80.0 fov = 90.0
[node name="HitBox" type="Area" parent="Head/Camera"] [node name="HitBox" type="Area" parent="Head/Camera"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0154071, -0.355, 0.246618 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0154071, -0.355, 0.246618 )
monitoring = false
monitorable = false monitorable = false
script = ExtResource( 7 ) script = ExtResource( 7 )
hitbox_type = 1 hitbox_type = 1
[node name="CollisionShape" type="CollisionShape" parent="Head/Camera/HitBox"] [node name="CollisionShape" type="CollisionShape" parent="Head/Camera/HitBox"]
transform = Transform( 1, 0, 0, 0, 0.3, 0, 0, 0, 0.8, 0, 0.414722, -1.5988 ) transform = Transform( 1, 0, 0, 0, 0.3, 0, 0, 0, 0.8, 0, 0.414722, -2.0674 )
shape = SubResource( 7 ) shape = SubResource( 7 )
[node name="PointTo" type="Spatial" parent="Head/Camera"] [node name="PointTo" type="Spatial" parent="Head/Camera"]

View File

@ -9,6 +9,17 @@ var movement = Vector3()
var direction = Vector3() var direction = Vector3()
var gravity_vec = Vector3() var gravity_vec = Vector3()
onready var hurtbox = $Hurtbox/HeadCollision
onready var hitbox = $HitBox/CollisionShape
onready var animation_player = $AnimationPlayer
func _ready():
animation_player.play("floating")
var rng = RandomNumberGenerator.new()
rng.randomize()
animation_player.seek(rng.randf_range(0.0,3.0))
animation_player.stop()
func _physics_process(delta): func _physics_process(delta):
velocity = velocity.linear_interpolate(direction * hit_speed, hit_acceleration * delta) velocity = velocity.linear_interpolate(direction * hit_speed, hit_acceleration * delta)
@ -19,8 +30,21 @@ func _physics_process(delta):
move_and_slide(movement, Vector3.UP) move_and_slide(movement, Vector3.UP)
func get_slapped(slap_level, slap_vector): if get_slide_count() > 0:
direction = slap_vector var collision = get_slide_collision(0)
if collision != null:
direction = direction.bounce(collision.normal)
func get_shot(): func get_slapped(slap_level, slap_kill, slap_vector):
if slap_level >= slap_kill:
animation_player.stop()
direction = slap_vector * slap_level
hurtbox.disabled = true
hitbox.disabled = false
func get_shot(hitboxOwner):
hitboxOwner.die()
die()
func die():
queue_free() queue_free()

View File

@ -1,27 +1,91 @@
[gd_scene load_steps=8 format=2] [gd_scene load_steps=14 format=2]
[ext_resource path="res://Scripts/HitBox.gd" type="Script" id=1] [ext_resource path="res://Scripts/HitBox.gd" type="Script" id=1]
[ext_resource path="res://Scenes/Enemy.gd" type="Script" id=2] [ext_resource path="res://Scenes/Enemy.gd" type="Script" id=2]
[ext_resource path="res://Scripts/HurtBox.gd" type="Script" id=3] [ext_resource path="res://Scripts/HurtBox.gd" type="Script" id=3]
[ext_resource path="res://Textures/MetalCorrodedHeavy001/MetalCorrodedHeavy001_METALNESS_1K_METALNESS.jpg" type="Texture" id=4]
[ext_resource path="res://Textures/MetalCorrodedHeavy001/MetalCorrodedHeavy001_Flat.jpg" type="Texture" id=5]
[ext_resource path="res://Textures/MetalCorrodedHeavy001/MetalCorrodedHeavy001_NRM_1K_METALNESS.jpg" type="Texture" id=6]
[sub_resource type="SphereMesh" id=6] [sub_resource type="SphereMesh" id=6]
[sub_resource type="SpatialMaterial" id=12]
albedo_color = Color( 0.74902, 0.992157, 0.776471, 0.341176 )
albedo_texture = ExtResource( 5 )
metallic_texture = ExtResource( 4 )
emission_enabled = true
emission = Color( 0, 0, 0, 1 )
emission_energy = 1.0
emission_operator = 0
emission_on_uv2 = false
normal_enabled = true
normal_scale = 1.0
normal_texture = ExtResource( 6 )
[sub_resource type="SphereShape" id=7] [sub_resource type="SphereShape" id=7]
[sub_resource type="SphereShape" id=8] [sub_resource type="SphereShape" id=8]
radius = 1.53964
[sub_resource type="SphereShape" id=9] [sub_resource type="SphereShape" id=9]
[sub_resource type="Animation" id=10]
length = 0.001
tracks/0/type = "value"
tracks/0/path = NodePath("MeshInstance:translation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Vector3( 0, -0.5, 0 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("MeshInstance:scale")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Vector3( 1, 1, 1 ) ]
}
[sub_resource type="Animation" id=11]
resource_name = "floating"
length = 3.0
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("MeshInstance:translation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 1.5, 3 ),
"transitions": PoolRealArray( 0.5, 0.5, 0.5 ),
"update": 0,
"values": [ Vector3( 0, -0.5, 0 ), Vector3( 0, 0.5, 0 ), Vector3( 0, -0.5, 0 ) ]
}
[node name="Enemy" type="KinematicBody"] [node name="Enemy" type="KinematicBody"]
script = ExtResource( 2 ) script = ExtResource( 2 )
[node name="MeshInstance" type="MeshInstance" parent="."] [node name="MeshInstance" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0 )
mesh = SubResource( 6 ) mesh = SubResource( 6 )
material/0 = SubResource( 12 )
[node name="Head" type="Area" parent="."] [node name="Hurtbox" type="Area" parent="."]
transform = Transform( 2.03634, 0, 0, 0, 2.03634, 0, 0, 0, 2.03634, 0, 0, 0 )
script = ExtResource( 3 ) script = ExtResource( 3 )
[node name="HeadCollision" type="CollisionShape" parent="Head"] [node name="HeadCollision" type="CollisionShape" parent="Hurtbox"]
shape = SubResource( 7 ) shape = SubResource( 7 )
[node name="EnemyCollision" type="CollisionShape" parent="."] [node name="EnemyCollision" type="CollisionShape" parent="."]
@ -29,8 +93,14 @@ transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.0
shape = SubResource( 8 ) shape = SubResource( 8 )
[node name="HitBox" type="Area" parent="."] [node name="HitBox" type="Area" parent="."]
transform = Transform( 1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.5, 0, 0, 0 )
script = ExtResource( 1 ) script = ExtResource( 1 )
hitbox_type = 2 hitbox_type = 2
[node name="CollisionShape" type="CollisionShape" parent="HitBox"] [node name="CollisionShape" type="CollisionShape" parent="HitBox"]
shape = SubResource( 9 ) shape = SubResource( 9 )
disabled = true
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/RESET = SubResource( 10 )
anims/floating = SubResource( 11 )

View File

@ -10,6 +10,7 @@ enum HitboxType{
export var hitbox_type = HitboxType.Unassigned export var hitbox_type = HitboxType.Unassigned
var slap_level = 0 var slap_level = 0
var slap_vector = Vector3() var slap_vector = Vector3()
var slap_kill = 0
func _init(): func _init():
collision_layer = 2 collision_layer = 2

View File

@ -15,6 +15,6 @@ func _on_area_entered(hitbox: HitBox):
return return
if hitbox.hitbox_type == hitbox.HitboxType.Slap and owner.has_method("get_slapped"): if hitbox.hitbox_type == hitbox.HitboxType.Slap and owner.has_method("get_slapped"):
owner.get_slapped(hitbox.slap_level, hitbox.slap_vector) owner.get_slapped(hitbox.slap_level,hitbox.slap_kill, hitbox.slap_vector)
elif hitbox.hitbox_type == hitbox.HitboxType.Projectile and owner.has_method("get_shot"): elif hitbox.hitbox_type == hitbox.HitboxType.Projectile and owner.has_method("get_shot"):
owner.get_shot() owner.get_shot(hitbox.owner)

6
Test_Scene.gd Normal file
View File

@ -0,0 +1,6 @@
extends Spatial
func _physics_process(delta):
if Input.is_action_just_pressed("reset_map"):
get_tree().reload_current_scene()

View File

@ -1,10 +1,15 @@
[gd_scene load_steps=8 format=2] [gd_scene load_steps=10 format=2]
[ext_resource path="res://Materials/Dark_ProtoMat.tres" type="Material" id=1] [ext_resource path="res://Materials/Dark_ProtoMat.tres" type="Material" id=1]
[ext_resource path="res://Player.tscn" type="PackedScene" id=2] [ext_resource path="res://Player.tscn" type="PackedScene" id=2]
[ext_resource path="res://Materials/Orange_ProtoMat.tres" type="Material" id=3] [ext_resource path="res://Materials/Orange_ProtoMat.tres" type="Material" id=3]
[ext_resource path="res://AllSkyFree_Skyboxes/Epic_BlueSunset_EquiRect_flat.png" type="Texture" id=4] [ext_resource path="res://AllSkyFree_Skyboxes/Epic_BlueSunset_EquiRect_flat.png" type="Texture" id=4]
[ext_resource path="res://Scenes/Enemy.tscn" type="PackedScene" id=5] [ext_resource path="res://Scenes/Enemy.tscn" type="PackedScene" id=5]
[ext_resource path="res://Test_Scene.gd" type="Script" id=6]
[sub_resource type="SpatialMaterial" id=3]
flags_transparent = true
albedo_color = Color( 0.894118, 0.894118, 0.894118, 0.211765 )
[sub_resource type="PanoramaSky" id=1] [sub_resource type="PanoramaSky" id=1]
panorama = ExtResource( 4 ) panorama = ExtResource( 4 )
@ -40,6 +45,7 @@ glow_hdr_threshold = 0.44
glow_bicubic_upscale = true glow_bicubic_upscale = true
[node name="Spatial" type="Spatial"] [node name="Spatial" type="Spatial"]
script = ExtResource( 6 )
[node name="CSGCombiner" type="CSGCombiner" parent="."] [node name="CSGCombiner" type="CSGCombiner" parent="."]
use_collision = true use_collision = true
@ -55,8 +61,18 @@ transform = Transform( 3.51681, 0, 0, 0, 4.16599, 0, 0, 0, 14.5504, 22.4026, 0,
polygon = PoolVector2Array( 0, 0, -3, 0, 1, 1, 1, 0 ) polygon = PoolVector2Array( 0, 0, -3, 0, 1, 1, 1, 0 )
material = ExtResource( 3 ) material = ExtResource( 3 )
[node name="CSGBox2" type="CSGBox" parent="CSGCombiner"]
transform = Transform( 21.115, 0, 0, 0, 13.92, 0, 0, 0, 1, -14.4011, 14, 36.3173 )
material = ExtResource( 3 )
[node name="CSGBox3" type="CSGBox" parent="CSGCombiner"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -18, 7.54811, 16 )
height = 14.0
depth = 14.0
material = SubResource( 3 )
[node name="Player" parent="." instance=ExtResource( 2 )] [node name="Player" parent="." instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9, 0 ) transform = Transform( -0.965926, 0, 0.258819, 0, 1, 0, -0.258819, 0, -0.965926, 0, 2.85127, 0 )
[node name="WorldEnvironment_EpicBlueSky" type="WorldEnvironment" parent="."] [node name="WorldEnvironment_EpicBlueSky" type="WorldEnvironment" parent="."]
environment = SubResource( 2 ) environment = SubResource( 2 )
@ -67,14 +83,14 @@ light_color = Color( 1, 0.924276, 0.869018, 1 )
light_specular = 1.0 light_specular = 1.0
shadow_enabled = true shadow_enabled = true
[node name="Enemy" parent="." instance=ExtResource( 5 )] [node name="Enemy1" parent="." instance=ExtResource( 5 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.367474, 2.61222, -26.0531 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -28, 5, 14.7642 )
[node name="Enemy2" parent="." instance=ExtResource( 5 )] [node name="Enemy2" parent="." instance=ExtResource( 5 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -7.44657, 2.62177, -26.1041 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -5, 5, 14.7812 )
[node name="Enemy3" parent="." instance=ExtResource( 5 )] [node name="DirectionalLight" type="DirectionalLight" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -16.3837, 2.53916, -26.4067 ) transform = Transform( 0.72831, 0.357922, 0.584342, 0.224814, -0.930353, 0.289658, 0.647319, -0.0795927, -0.758052, -51.5559, 23.8185, -5.9078 )
light_energy = 1.734
[node name="Enemy4" parent="." instance=ExtResource( 5 )] light_indirect_energy = 3.789
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 5.17381, 2.57569, -26.2299 ) light_specular = 0.499

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="StreamTexture"
path.s3tc="res://.import/MetalCorrodedHeavy001_Flat.jpg-5a6d8dbc6f8d7132a4683f83c8a38e21.s3tc.stex"
path.etc2="res://.import/MetalCorrodedHeavy001_Flat.jpg-5a6d8dbc6f8d7132a4683f83c8a38e21.etc2.stex"
metadata={
"imported_formats": [ "s3tc", "etc2" ],
"vram_texture": true
}
[deps]
source_file="res://Textures/MetalCorrodedHeavy001/MetalCorrodedHeavy001_Flat.jpg"
dest_files=[ "res://.import/MetalCorrodedHeavy001_Flat.jpg-5a6d8dbc6f8d7132a4683f83c8a38e21.s3tc.stex", "res://.import/MetalCorrodedHeavy001_Flat.jpg-5a6d8dbc6f8d7132a4683f83c8a38e21.etc2.stex" ]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=true
flags/filter=true
flags/mipmaps=true
flags/anisotropic=false
flags/srgb=1
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

View File

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="StreamTexture"
path.s3tc="res://.import/MetalCorrodedHeavy001_METALNESS_1K_METALNESS.jpg-3207c1776cded682c1ff9828c6f671be.s3tc.stex"
path.etc2="res://.import/MetalCorrodedHeavy001_METALNESS_1K_METALNESS.jpg-3207c1776cded682c1ff9828c6f671be.etc2.stex"
metadata={
"imported_formats": [ "s3tc", "etc2" ],
"vram_texture": true
}
[deps]
source_file="res://Textures/MetalCorrodedHeavy001/MetalCorrodedHeavy001_METALNESS_1K_METALNESS.jpg"
dest_files=[ "res://.import/MetalCorrodedHeavy001_METALNESS_1K_METALNESS.jpg-3207c1776cded682c1ff9828c6f671be.s3tc.stex", "res://.import/MetalCorrodedHeavy001_METALNESS_1K_METALNESS.jpg-3207c1776cded682c1ff9828c6f671be.etc2.stex" ]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=true
flags/filter=true
flags/mipmaps=true
flags/anisotropic=false
flags/srgb=1
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="StreamTexture"
path.s3tc="res://.import/MetalCorrodedHeavy001_NRM_1K_METALNESS.jpg-1917dfccc22f092038b0fe7fa7c9d9d8.s3tc.stex"
path.etc2="res://.import/MetalCorrodedHeavy001_NRM_1K_METALNESS.jpg-1917dfccc22f092038b0fe7fa7c9d9d8.etc2.stex"
metadata={
"imported_formats": [ "s3tc", "etc2" ],
"vram_texture": true
}
[deps]
source_file="res://Textures/MetalCorrodedHeavy001/MetalCorrodedHeavy001_NRM_1K_METALNESS.jpg"
dest_files=[ "res://.import/MetalCorrodedHeavy001_NRM_1K_METALNESS.jpg-1917dfccc22f092038b0fe7fa7c9d9d8.s3tc.stex", "res://.import/MetalCorrodedHeavy001_NRM_1K_METALNESS.jpg-1917dfccc22f092038b0fe7fa7c9d9d8.etc2.stex" ]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=1
flags/repeat=true
flags/filter=true
flags/mipmaps=true
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

View File

@ -96,6 +96,11 @@ crouch={
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777238,"physical_scancode":0,"unicode":0,"echo":false,"script":null) "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777238,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
] ]
} }
reset_map={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":82,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}
[physics] [physics]