groovin it
This commit is contained in:
parent
3c62183156
commit
783fc7c877
9 changed files with 311 additions and 21 deletions
|
|
@ -2,9 +2,17 @@ class_name Groove
|
|||
extends CharacterBody2D
|
||||
|
||||
|
||||
@export var max_length: float
|
||||
@export var rest_length: float
|
||||
@export var springiness: float
|
||||
@export var damping: float
|
||||
@export var player: Player
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
pass
|
||||
var length = global_position.distance_to(player.global_position)
|
||||
var tension = length - rest_length
|
||||
if tension > 0:
|
||||
var force = tension * springiness
|
||||
velocity += global_position.direction_to(player.global_position) * force * delta
|
||||
velocity -= velocity * damping * delta
|
||||
move_and_slide()
|
||||
|
|
|
|||
|
|
@ -8,24 +8,6 @@
|
|||
[sub_resource type="CircleShape2D" id="CircleShape2D_cqmt1"]
|
||||
radius = 12.0
|
||||
|
||||
[sub_resource type="Animation" id="Animation_g7ett"]
|
||||
resource_name = "walk"
|
||||
length = 0.3
|
||||
loop_mode = 1
|
||||
step = 0.05
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:flip_h")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.15),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 1,
|
||||
"values": [true, false]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_ssrue"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
|
|
@ -58,6 +40,24 @@ tracks/0/keys = {
|
|||
"values": [false]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_g7ett"]
|
||||
resource_name = "walk"
|
||||
length = 0.3
|
||||
loop_mode = 1
|
||||
step = 0.05
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:flip_h")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.15),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 1,
|
||||
"values": [true, false]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_gnkmh"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_ssrue"),
|
||||
|
|
@ -89,7 +89,9 @@ libraries = {
|
|||
[node name="Groove" type="CharacterBody2D" parent="Node" node_paths=PackedStringArray("player")]
|
||||
position = Vector2(64, 0)
|
||||
script = ExtResource("3_jnjyq")
|
||||
max_length = 64.0
|
||||
rest_length = 64.0
|
||||
springiness = 16.0
|
||||
damping = 0.5
|
||||
player = NodePath("../..")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="Node/Groove"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue