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

@@ -9,6 +9,17 @@ var movement = Vector3()
var direction = 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):
velocity = velocity.linear_interpolate(direction * hit_speed, hit_acceleration * delta)
@@ -18,9 +29,22 @@ func _physics_process(delta):
movement.z = velocity.z
move_and_slide(movement, Vector3.UP)
func get_slapped(slap_level, slap_vector):
direction = slap_vector
func get_shot():
if get_slide_count() > 0:
var collision = get_slide_collision(0)
if collision != null:
direction = direction.bounce(collision.normal)
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()

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://Scenes/Enemy.gd" type="Script" id=2]
[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="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=8]
radius = 1.53964
[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"]
script = ExtResource( 2 )
[node name="MeshInstance" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0 )
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 )
[node name="HeadCollision" type="CollisionShape" parent="Head"]
[node name="HeadCollision" type="CollisionShape" parent="Hurtbox"]
shape = SubResource( 7 )
[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 )
[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 )
hitbox_type = 2
[node name="CollisionShape" type="CollisionShape" parent="HitBox"]
shape = SubResource( 9 )
disabled = true
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/RESET = SubResource( 10 )
anims/floating = SubResource( 11 )