Basic launch
This commit is contained in:
parent
463f1c5cda
commit
82774ae786
52
Player.gd
52
Player.gd
@ -10,7 +10,8 @@ export var jump = 30
|
||||
export var slapkill = 0.8
|
||||
var slap = 0.0
|
||||
var chargeSlap = false
|
||||
var isSlap = false;
|
||||
var isSlap = false
|
||||
var can_slap = true
|
||||
|
||||
export var mouse_sensitivity = 0.03
|
||||
|
||||
@ -23,12 +24,16 @@ var movement = Vector3()
|
||||
var gravity_vec = Vector3()
|
||||
|
||||
onready var head = $Head
|
||||
onready var camera = $Head/Camera
|
||||
onready var point_to = $Head/Camera/PointTo
|
||||
onready var ground_check = $GroundCheck
|
||||
onready var slap_gauge = $HUD/PlayerLayer/ActualHUD/SlapGauge
|
||||
onready var slap_animator = $HandMovement
|
||||
onready var Menu = $HUD/MenuLayer/Start
|
||||
onready var AudioSlap = $AudioSlap
|
||||
onready var AudioMegaSlap = $AudioMegaSlap
|
||||
onready var hitbox = $Head/Camera/HitBox
|
||||
onready var slap_cooldown = $SlapCooldown
|
||||
|
||||
func _ready():
|
||||
slap_animator.current_animation = "basic_slap"
|
||||
@ -68,6 +73,11 @@ func _physics_process(delta):
|
||||
if Input.is_action_just_pressed("jump") and (is_on_floor() or ground_check.is_colliding()):
|
||||
gravity_vec = Vector3.UP * jump
|
||||
|
||||
if Input.is_action_just_pressed("crouch"):
|
||||
head.translate(Vector3.DOWN)
|
||||
if Input.is_action_just_released("crouch"):
|
||||
head.translate(Vector3.UP)
|
||||
|
||||
if Input.is_action_pressed("move_forward"):
|
||||
direction -= transform.basis.z
|
||||
elif Input.is_action_pressed("move_backward"):
|
||||
@ -78,21 +88,27 @@ func _physics_process(delta):
|
||||
direction += transform.basis.x
|
||||
|
||||
# Slappening
|
||||
if Input.is_action_pressed("slap"):
|
||||
if slap < 0.01:
|
||||
chargeSlap = true;
|
||||
elif Input.is_action_just_released("slap"):
|
||||
if chargeSlap:
|
||||
isSlap = true;
|
||||
chargeSlap = false;
|
||||
else:
|
||||
isSlap = false;
|
||||
|
||||
if isSlap:
|
||||
if slap >= slapkill:
|
||||
AudioMegaSlap.play()
|
||||
if can_slap:
|
||||
if Input.is_action_pressed("slap"):
|
||||
if slap < 0.01:
|
||||
chargeSlap = true;
|
||||
elif Input.is_action_just_released("slap"):
|
||||
if chargeSlap:
|
||||
isSlap = true;
|
||||
chargeSlap = false;
|
||||
can_slap = false
|
||||
slap_cooldown.start(0.25)
|
||||
else:
|
||||
AudioSlap.play()
|
||||
isSlap = false;
|
||||
|
||||
if isSlap:
|
||||
if slap >= slapkill:
|
||||
AudioMegaSlap.play()
|
||||
else:
|
||||
AudioSlap.play()
|
||||
hitbox.monitorable = true
|
||||
hitbox.slap_level = slap
|
||||
hitbox.slap_vector = point_to.get_global_transform().origin - camera.get_global_transform().origin
|
||||
|
||||
if (chargeSlap):
|
||||
slap += delta * 1.5;
|
||||
@ -116,3 +132,9 @@ func _physics_process(delta):
|
||||
|
||||
# warning-ignore:return_value_discarded
|
||||
move_and_slide(movement, Vector3.UP)
|
||||
|
||||
|
||||
func _on_SlapCooldown_timeout():
|
||||
can_slap = true
|
||||
slap_cooldown.stop()
|
||||
hitbox.monitorable = false
|
||||
|
24
Player.tscn
24
Player.tscn
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=12 format=2]
|
||||
[gd_scene load_steps=14 format=2]
|
||||
|
||||
[ext_resource path="res://Player.gd" type="Script" id=1]
|
||||
[ext_resource path="res://BlenderStuff/Hand/protohand.obj" type="ArrayMesh" id=2]
|
||||
@ -6,12 +6,16 @@
|
||||
[ext_resource path="res://HUD.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://Audio/80-s-clap.wav" type="AudioStream" id=5]
|
||||
[ext_resource path="res://Audio/MegaSlap.wav" type="AudioStream" id=6]
|
||||
[ext_resource path="res://Scripts/HitBox.gd" type="Script" id=7]
|
||||
|
||||
[sub_resource type="CapsuleShape" id=2]
|
||||
height = 3.0
|
||||
|
||||
[sub_resource type="CylinderShape" id=3]
|
||||
|
||||
[sub_resource type="BoxShape" id=7]
|
||||
extents = Vector3( 0.797679, 1, 1 )
|
||||
|
||||
[sub_resource type="SpatialMaterial" id=4]
|
||||
flags_no_depth_test = true
|
||||
albedo_texture = ExtResource( 3 )
|
||||
@ -101,6 +105,19 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.84218, 0 )
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0154071, 0.355, -0.246618 )
|
||||
fov = 80.0
|
||||
|
||||
[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 )
|
||||
monitorable = false
|
||||
script = ExtResource( 7 )
|
||||
hitbox_type = 1
|
||||
|
||||
[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 )
|
||||
shape = SubResource( 7 )
|
||||
|
||||
[node name="PointTo" type="Spatial" parent="Head/Camera"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1 )
|
||||
|
||||
[node name="HandParent" type="Spatial" parent="Head"]
|
||||
transform = Transform( 0.0807126, 0.49343, -0.00351894, 0.445393, -0.0713166, 0.215728, 0.212391, -0.0379586, -0.451053, 0.736, -0.075, -1.998 )
|
||||
|
||||
@ -133,3 +150,8 @@ doppler_tracking = 2
|
||||
[node name="Music" type="AudioStreamPlayer" parent="."]
|
||||
volume_db = 13.983
|
||||
autoplay = true
|
||||
|
||||
[node name="SlapCooldown" type="Timer" parent="."]
|
||||
wait_time = 0.5
|
||||
|
||||
[connection signal="timeout" from="SlapCooldown" to="." method="_on_SlapCooldown_timeout"]
|
||||
|
25
Scenes/Enemy.gd
Normal file
25
Scenes/Enemy.gd
Normal file
@ -0,0 +1,25 @@
|
||||
extends KinematicBody
|
||||
|
||||
onready var animation_player = $AnimationPlayer
|
||||
|
||||
var hit_acceleration = 10
|
||||
var hit_speed = 100
|
||||
|
||||
var velocity = Vector3()
|
||||
var movement = Vector3()
|
||||
var direction = Vector3()
|
||||
var gravity_vec = Vector3()
|
||||
|
||||
func _physics_process(delta):
|
||||
|
||||
velocity = velocity.linear_interpolate(direction * hit_speed, hit_acceleration * delta)
|
||||
|
||||
movement.x = velocity.x
|
||||
movement.y = velocity.y
|
||||
movement.z = velocity.z
|
||||
|
||||
move_and_slide(movement, Vector3.UP)
|
||||
|
||||
func get_slapped(slap_level, slap_vector):
|
||||
animation_player.play("head_wobble")
|
||||
direction = slap_vector
|
@ -1,21 +1,70 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
[gd_scene load_steps=9 format=2]
|
||||
|
||||
[ext_resource path="res://BlenderStuff/protoenemy.obj" type="ArrayMesh" id=1]
|
||||
[ext_resource path="res://Scenes/Enemy.gd" type="Script" id=2]
|
||||
[ext_resource path="res://Scripts/HurtBox.gd" type="Script" id=3]
|
||||
|
||||
[sub_resource type="BoxShape" id=1]
|
||||
|
||||
[sub_resource type="BoxShape" id=2]
|
||||
[sub_resource type="CapsuleShape" id=2]
|
||||
height = 2.5
|
||||
|
||||
[sub_resource type="CylinderShape" id=3]
|
||||
|
||||
[sub_resource type="Animation" id=4]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("MeshInstance:rotation_degrees")
|
||||
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, -15 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=5]
|
||||
resource_name = "head_wobble"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("MeshInstance:rotation_degrees")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.1, 0.3, 0.5 ),
|
||||
"transitions": PoolRealArray( 1, 2.07053, 1, 0.482968 ),
|
||||
"update": 0,
|
||||
"values": [ Vector3( 0, 0, 0 ), Vector3( 0, 0, -15 ), Vector3( 0, 0, 15 ), Vector3( 0, 0, 0 ) ]
|
||||
}
|
||||
|
||||
[node name="Enemy" type="KinematicBody"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="MeshInstance" type="MeshInstance" parent="."]
|
||||
transform = Transform( 0.6, 0, 0, 0, 0.6, 0, 0, 0, 0.6, 0, 0, 0 )
|
||||
mesh = ExtResource( 1 )
|
||||
|
||||
[node name="BodyCollision" type="CollisionShape" parent="."]
|
||||
transform = Transform( 0.914478, 0, 0, 0, 1.50713, 0, 0, 0, 0.383312, 0, -0.479353, 0 )
|
||||
[node name="Head" type="Area" parent="."]
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="HeadCollision" type="CollisionShape" parent="Head"]
|
||||
transform = Transform( 0.432688, 0, 0, 0, 2.49394, 0, 0, 0, 0.432688, 0, -0.0876949, 0 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="Head" type="CollisionShape" parent="."]
|
||||
transform = Transform( 0.528959, 0, 0, 0, 0.728767, 0, 0, 0, 0.528959, 0, 1.87623, 0 )
|
||||
[node name="EnemyCollision" type="CollisionShape" parent="."]
|
||||
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, -0.094023, 0 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="EnemyFeet" type="CollisionShape" parent="."]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.59606, 0 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
reset_on_save = false
|
||||
anims/RESET = SubResource( 4 )
|
||||
anims/head_wobble = SubResource( 5 )
|
||||
|
16
Scripts/HitBox.gd
Normal file
16
Scripts/HitBox.gd
Normal file
@ -0,0 +1,16 @@
|
||||
class_name HitBox
|
||||
extends Area
|
||||
|
||||
enum HitboxType{
|
||||
Unassigned,
|
||||
Slap,
|
||||
Projectile,
|
||||
}
|
||||
|
||||
export var hitbox_type = HitboxType.Unassigned
|
||||
var slap_level = 0
|
||||
var slap_vector = Vector3()
|
||||
|
||||
func _init():
|
||||
collision_layer = 2
|
||||
collision_mask = 0
|
20
Scripts/HurtBox.gd
Normal file
20
Scripts/HurtBox.gd
Normal file
@ -0,0 +1,20 @@
|
||||
class_name HurtBox
|
||||
extends Area
|
||||
|
||||
func _init():
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
|
||||
func _ready():
|
||||
connect("area_entered",self,"_on_area_entered")
|
||||
|
||||
func _on_area_entered(hitbox: HitBox):
|
||||
if hitbox == null:
|
||||
return
|
||||
if hitbox.hitbox_type == hitbox.HitboxType.Unassigned:
|
||||
return
|
||||
|
||||
if hitbox.hitbox_type == hitbox.HitboxType.Slap and owner.has_method("get_slapped"):
|
||||
owner.get_slapped(hitbox.slap_level, hitbox.slap_vector)
|
||||
elif hitbox.hitbox_type == hitbox.HitboxType.Projectile and owner.has_method("get_shot"):
|
||||
owner.get_shot()
|
@ -69,3 +69,12 @@ shadow_enabled = true
|
||||
|
||||
[node name="Enemy" parent="." instance=ExtResource( 5 )]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.367474, 2.61222, -26.0531 )
|
||||
|
||||
[node name="Enemy2" parent="." instance=ExtResource( 5 )]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -7.44657, 2.62177, -26.1041 )
|
||||
|
||||
[node name="Enemy3" parent="." instance=ExtResource( 5 )]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -16.3837, 2.53916, -26.4067 )
|
||||
|
||||
[node name="Enemy4" parent="." instance=ExtResource( 5 )]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 5.17381, 2.57569, -26.2299 )
|
||||
|
@ -8,6 +8,22 @@
|
||||
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ {
|
||||
"base": "Area",
|
||||
"class": "HitBox",
|
||||
"language": "GDScript",
|
||||
"path": "res://Scripts/HitBox.gd"
|
||||
}, {
|
||||
"base": "Area",
|
||||
"class": "HurtBox",
|
||||
"language": "GDScript",
|
||||
"path": "res://Scripts/HurtBox.gd"
|
||||
} ]
|
||||
_global_script_class_icons={
|
||||
"HitBox": "",
|
||||
"HurtBox": ""
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Slap"
|
||||
@ -74,6 +90,18 @@ escape={
|
||||
"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":16777217,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
crouch={
|
||||
"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":16777238,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[layer_names]
|
||||
|
||||
3d_render/layer_1="world"
|
||||
3d_render/layer_2="hitboxes"
|
||||
3d_physics/layer_1="world"
|
||||
3d_physics/layer_2="hitboxes"
|
||||
|
||||
[physics]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user