bonkjj st!
This commit is contained in:
parent
dd66cc2a84
commit
7d20cb9bcc
4 changed files with 38 additions and 6 deletions
|
|
@ -16,3 +16,8 @@ func _physics_process(delta: float) -> void:
|
||||||
velocity += global_position.direction_to(player.global_position) * force * delta
|
velocity += global_position.direction_to(player.global_position) * force * delta
|
||||||
velocity -= velocity * damping * delta
|
velocity -= velocity * damping * delta
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_hitbox_body_entered(body: Node2D) -> void:
|
||||||
|
if body.has_method(&"knock"):
|
||||||
|
body.knock(global_position.direction_to(body.global_position) * velocity.length())
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,18 @@ extends CharacterBody2D
|
||||||
|
|
||||||
|
|
||||||
@export var walk_speed: float
|
@export var walk_speed: float
|
||||||
|
@export var stun_factor: float
|
||||||
|
|
||||||
@export_group("Internal References")
|
@export_group("Internal References")
|
||||||
@export var _animations: AnimationPlayer
|
@export var _animations: AnimationPlayer
|
||||||
|
|
||||||
|
|
||||||
var is_stunned := false
|
var stun_time: float = 0.0
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
if is_stunned:
|
if stun_time > 0.0:
|
||||||
pass
|
stun_time -= delta
|
||||||
else:
|
else:
|
||||||
var input_dir = Input.get_vector(&"move_left", &"move_right", &"move_up", &"move_down")
|
var input_dir = Input.get_vector(&"move_left", &"move_right", &"move_up", &"move_down")
|
||||||
velocity = input_dir * walk_speed
|
velocity = input_dir * walk_speed
|
||||||
|
|
@ -23,3 +24,15 @@ func _physics_process(delta: float) -> void:
|
||||||
_animations.play(&"walk")
|
_animations.play(&"walk")
|
||||||
|
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
|
|
||||||
|
func knock(force: Vector2) -> void:
|
||||||
|
velocity = force
|
||||||
|
stun_time = force.length() / stun_factor
|
||||||
|
|
||||||
|
|
||||||
|
#func _on_hurtbox_body_entered(body: Node2D) -> void:
|
||||||
|
#if body is Groove:
|
||||||
|
#var dir = body.global_position.direction_to(global_position)
|
||||||
|
#velocity = dir * body.velocity.length()
|
||||||
|
#stun_time = 0.5
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=11 format=3 uid="uid://djpowg53xsgux"]
|
[gd_scene load_steps=12 format=3 uid="uid://djpowg53xsgux"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://by3eww6d7boay" path="res://objects/player/player.gd" id="1_cqmt1"]
|
[ext_resource type="Script" uid="uid://by3eww6d7boay" path="res://objects/player/player.gd" id="1_cqmt1"]
|
||||||
[ext_resource type="Texture2D" uid="uid://b0myjj8ggu2gt" path="res://assets/graphics/splint.png" id="2_g7ett"]
|
[ext_resource type="Texture2D" uid="uid://b0myjj8ggu2gt" path="res://assets/graphics/splint.png" id="2_g7ett"]
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
[ext_resource type="Texture2D" uid="uid://dgclvsxcplj81" path="res://assets/graphics/groove.png" id="3_ssrue"]
|
[ext_resource type="Texture2D" uid="uid://dgclvsxcplj81" path="res://assets/graphics/groove.png" id="3_ssrue"]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_cqmt1"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_cqmt1"]
|
||||||
radius = 12.0
|
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_ssrue"]
|
[sub_resource type="Animation" id="Animation_ssrue"]
|
||||||
length = 0.001
|
length = 0.001
|
||||||
|
|
@ -67,10 +66,14 @@ _data = {
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_ssrue"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_ssrue"]
|
||||||
|
|
||||||
[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("_animations")]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_jnjyq"]
|
||||||
|
radius = 12.0
|
||||||
|
|
||||||
|
[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("_animations") groups=["knockable"]]
|
||||||
motion_mode = 1
|
motion_mode = 1
|
||||||
script = ExtResource("1_cqmt1")
|
script = ExtResource("1_cqmt1")
|
||||||
walk_speed = 100.0
|
walk_speed = 100.0
|
||||||
|
stun_factor = 200.0
|
||||||
_animations = NodePath("AnimationPlayer")
|
_animations = NodePath("AnimationPlayer")
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
|
@ -99,3 +102,10 @@ texture = ExtResource("3_ssrue")
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Node/Groove"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Node/Groove"]
|
||||||
shape = SubResource("CircleShape2D_ssrue")
|
shape = SubResource("CircleShape2D_ssrue")
|
||||||
|
|
||||||
|
[node name="Hitbox" type="Area2D" parent="Node/Groove"]
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Node/Groove/Hitbox"]
|
||||||
|
shape = SubResource("CircleShape2D_jnjyq")
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="Node/Groove/Hitbox" to="Node/Groove" method="_on_hitbox_body_entered"]
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,10 @@ folder_colors={
|
||||||
"res://objects/": "blue"
|
"res://objects/": "blue"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global_group]
|
||||||
|
|
||||||
|
knockable="Can be knocked around by Groove."
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
move_left={
|
move_left={
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue