fix: platforms are tweens, enemies hurting fix

Enemies now make the player die
(would be better with event)
This resolves blobby detecting being killed
whilst stomping
This commit is contained in:
Jakob Feldmann 2023-08-04 20:56:17 +02:00
parent 328abd6b54
commit 8021aa1bf5
20 changed files with 293 additions and 427 deletions

View File

@ -231,7 +231,7 @@ func is_touching_wall_completely() -> bool:
# Attached to wall state is in the PlayerStateMachine
func is_correct_walljump_input(direction: Vector2) -> bool:
return (
Input.is_action_pressed("jump")
Input.is_action_just_pressed("jump")
&& abs(direction.x + wall_touch_direction) < 1
&& abs(direction.x + wall_touch_direction) >= 0
)
@ -429,6 +429,7 @@ func receive_power_up(kind: String) -> void:
# TODO Maybe this should be a state in itself?
func die(animation_number: int = 0) -> void:
if levelState.is_dead: return
if shielded:
shielded = false
$BubbleShieldViewport/IridescenceBall.visible = false
@ -458,16 +459,11 @@ func respawn() -> void:
# When the Enemy stomp AREA enters the enemy collision area -> stomp
func _on_BlobbySkin_area_entered(area: Area2D) -> void:
if area.is_in_group("harmful") && !levelState.is_dead:
if area.is_in_group("harmful"):
die()
if area.is_in_group("pit"):
$PitfallTimer.start()
# When the Enemy collision BODY enters the enemy collision area -> die
func _on_BlobbySkin_body_entered(body: Node) -> void:
if body.is_in_group("harmful") && !levelState.is_dead:
die()
# This problem stems from trying to decelerate a walk
# that was caused by the moving environment and not by input
# It is particularly usefull for moving floor physics

View File

@ -4396,6 +4396,8 @@ one_shot = true
wait_time = 0.809
one_shot = true
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
[connection signal="area_entered" from="BlobbySkin" to="." method="_on_BlobbySkin_area_entered"]
[connection signal="body_entered" from="BlobbySkin" to="." method="_on_BlobbySkin_body_entered"]
[connection signal="got_grounded" from="BlobbyStateMachine" to="." method="_on_Blobby_got_grounded"]

View File

@ -4,19 +4,20 @@
[ext_resource path="res://src/Actors/Enemies/Beings/Caterpillar.gd" type="Script" id=2]
[ext_resource path="res://src/StateMachines/CaterpillarStateMachine.gd" type="Script" id=3]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 14.7108, 7.85442 )
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 15, 6 )
extents = Vector2( 13.3735, 3.49085 )
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 15, 12 )
extents = Vector2( 15, 8.61814 )
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 14.7108, 7.85442 )
[node name="Caterpillar" type="KinematicBody2D" groups=["harmful"]]
scale = Vector2( 0.747749, 0.572926 )
collision_layer = 2
collision_mask = 9
collision/safe_margin = 0.001
script = ExtResource( 2 )
[node name="enemy" type="Sprite" parent="."]
@ -31,10 +32,6 @@ rect = Rect2( -89, -10, 2, 20 )
process_parent = true
physics_process_parent = true
[node name="EnemyBody" type="CollisionShape2D" parent="."]
position = Vector2( -6.37697e-07, 4.36357 )
shape = SubResource( 1 )
[node name="SlopeRaycastLeft" type="RayCast2D" parent="."]
position = Vector2( -7.5, 12 )
enabled = true
@ -66,21 +63,29 @@ position = Vector2( 0, -6.44095 )
collision_layer = 2
input_pickable = false
monitorable = false
priority = 1.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="StompDetector"]
position = Vector2( 0, 0.440949 )
position = Vector2( 0, -2.28618 )
shape = SubResource( 2 )
[node name="EnemySkin" type="Area2D" parent="." groups=["player"]]
process_priority = -1
collision_layer = 2
collision_mask = 126
collision_mask = 127
input_pickable = false
[node name="CollisionPolygon2D" type="CollisionShape2D" parent="EnemySkin"]
position = Vector2( 0, 3.49085 )
shape = SubResource( 3 )
[node name="EnemyBody" type="CollisionShape2D" parent="."]
position = Vector2( -6.37697e-07, 4.36357 )
shape = SubResource( 1 )
[node name="StateMachine" type="Node2D" parent="."]
script = ExtResource( 3 )
[connection signal="body_entered" from="StompDetector" to="." method="_on_StompDetector_body_entered"]
[connection signal="area_entered" from="EnemySkin" to="." method="_on_EnemySkin_area_entered"]
[connection signal="body_entered" from="EnemySkin" to="." method="_on_EnemySkin_body_entered"]

View File

@ -6,30 +6,29 @@ export var speed := 80
export var acceleration := 80
func _ready() -> void:
set_physics_process(false)
$StompDetector.monitoring = !invincible
$StompDetector.monitoring = !invincible
# TODO Only moves when on screen
func _physics_process(delta: float) -> void:
velocity.y += _gravity * delta
var player_direction := player_on_floor_direction()
if(player_direction != 0):
velocity.x = PhysicsFunc.two_step_euler(velocity.x, acceleration * player_direction,
mass, delta)
velocity.x = clamp(velocity.x, -speed, speed)
else:
velocity.x = PhysicsFunc.two_step_euler(velocity.x, acceleration * -sign(velocity.x),
mass, delta)
velocity.y += _gravity * delta
var player_direction := player_on_floor_direction()
if(player_direction != 0):
velocity.x = PhysicsFunc.two_step_euler(velocity.x, acceleration * player_direction,
mass, delta)
velocity.x = clamp(velocity.x, -speed, speed)
else:
velocity.x = PhysicsFunc.two_step_euler(velocity.x, acceleration * -sign(velocity.x),
mass, delta)
velocity.y = move_and_slide(velocity, FLOOR_NORMAL).y
velocity.y = move_and_slide(velocity, FLOOR_NORMAL).y
# TODO Detects player over gaps
func player_on_floor_direction() -> float:
for raycast in $LedgeDetectorRays.get_children():
if raycast.is_colliding():
var collider = raycast.get_collider()
if collider.is_in_group("player"):
return sign(collider.position.x - self.position.x)
return 0.0
for raycast in $LedgeDetectorRays.get_children():
if raycast.is_colliding():
var collider = raycast.get_collider()
if collider.is_in_group("player"):
return sign(collider.position.x - self.position.x)
return 0.0

View File

@ -4,13 +4,13 @@
[ext_resource path="res://src/Actors/Enemies/Beings/DartingEnemy.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 15, 7.5 )
extents = Vector2( 15, 9 )
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 15, 4.51505 )
extents = Vector2( 14, 1.5 )
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 15.534, 10.0962 )
extents = Vector2( 15.534, 9.5 )
[node name="DartingEnemy" type="KinematicBody2D" groups=["harmful"]]
collision_layer = 2
@ -18,7 +18,6 @@ collision_mask = 9
script = ExtResource( 2 )
[node name="enemy" type="Sprite" parent="."]
position = Vector2( 0, -1.90735e-06 )
scale = Vector2( 0.286789, 0.276348 )
texture = ExtResource( 1 )
@ -29,8 +28,8 @@ rect = Rect2( -89, -10, 2, 20 )
process_parent = true
physics_process_parent = true
[node name="EnemyBody" type="CollisionShape2D" parent="." groups=["harmful"]]
position = Vector2( -4.76837e-07, 4.5 )
[node name="EnemyBody" type="CollisionShape2D" parent="."]
position = Vector2( -4.76837e-07, 4 )
shape = SubResource( 1 )
[node name="StompDetector" type="Area2D" parent="." groups=["weakpoint"]]
@ -40,7 +39,7 @@ collision_layer = 2
input_pickable = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="StompDetector"]
position = Vector2( 0, -1.044 )
position = Vector2( 0, -3.55905 )
shape = SubResource( 2 )
[node name="LedgeDetectorRays" type="Node2D" parent="."]
@ -63,12 +62,13 @@ collision_mask = 121
[node name="EnemySkin" type="Area2D" parent="." groups=["player"]]
process_priority = -1
visible = false
collision_mask = 126
collision_layer = 2
collision_mask = 127
[node name="CollisionPolygon2D" type="CollisionShape2D" parent="EnemySkin"]
position = Vector2( -8.07794e-28, 1.5 )
position = Vector2( 0, 2.5 )
shape = SubResource( 3 )
[connection signal="body_entered" from="StompDetector" to="." method="_on_StompDetector_body_entered"]
[connection signal="area_entered" from="EnemySkin" to="." method="_on_EnemySkin_area_entered"]
[connection signal="body_entered" from="EnemySkin" to="." method="_on_EnemySkin_body_entered"]

View File

@ -1,13 +1,18 @@
extends Actor
class_name Enemy
var player_entered_stomp = false
func _on_StompDetector_body_entered(body: Node) -> void:
if !body.is_in_group("player"):
return
player_entered_stomp = true
var incoming_vel_vector: Vector2 = body.velocity.normalized()
print(rad2deg(abs(incoming_vel_vector.angle_to(Vector2.DOWN.rotated(rotation)))))
if abs(incoming_vel_vector.angle_to(Vector2.DOWN.rotated(rotation))) > deg2rad(90):
print("too shallow entry")
body.die()
player_entered_stomp = false
return
signalManager.emit_signal("got_stomped")
remove_from_group("harmful")
@ -24,3 +29,7 @@ func _on_EnemySkin_area_entered(area:Area2D) -> void:
if area.is_in_group("harmful"):
get_node("EnemyBody").disabled = true
die()
func _on_EnemySkin_body_entered(body: Node) -> void:
if body.is_in_group("player") && !player_entered_stomp:
body.die()

View File

@ -38,126 +38,126 @@ var detect_timer := 0.0
func _ready():
spawn_avoidance_raycasts(16, 20)
target_lost_timer = Timer.new()
target_lost_timer.set_one_shot(true)
target_lost_timer.connect("timeout", self, "lose_target")
add_child(target_lost_timer)
update_navigation_timer = Timer.new()
update_navigation_timer.connect("timeout", self, "update_navigation")
add_child(update_navigation_timer)
update_navigation_timer.start(0.3)
# TODO Hat immer den Spawn im Patrolpath
patrol_waypoints.append(global_position)
for waypoint in $PatrolPath.get_children():
patrol_waypoints.append(waypoint.global_position)
pass
spawn_avoidance_raycasts(16, 20)
target_lost_timer = Timer.new()
target_lost_timer.set_one_shot(true)
target_lost_timer.connect("timeout", self, "lose_target")
add_child(target_lost_timer)
update_navigation_timer = Timer.new()
update_navigation_timer.connect("timeout", self, "update_navigation")
add_child(update_navigation_timer)
update_navigation_timer.start(0.3)
# TODO Hat immer den Spawn im Patrolpath
patrol_waypoints.append(global_position)
for waypoint in $PatrolPath.get_children():
patrol_waypoints.append(waypoint.global_position)
pass
func searching() -> Vector2:
slow_down_factor = patrolling_slowdown
if(aggressive && detect_timer > 0.33):
detect_player()
detect_timer = 0.0
if(patrolling && nav_agent.is_target_reached()):
next_waypoint = get_next_patrol_target()
update_navigation()
elif(patrolling):
next_waypoint = patrol_waypoints[patrol_waypoint_index]
else:
# Spawn location
return patrol_waypoints[0]
return nav_agent.get_next_location()
slow_down_factor = patrolling_slowdown
if(aggressive && detect_timer > 0.33):
detect_player()
detect_timer = 0.0
if(patrolling && nav_agent.is_target_reached()):
next_waypoint = get_next_patrol_target()
update_navigation()
elif(patrolling):
next_waypoint = patrol_waypoints[patrol_waypoint_index]
else:
# Spawn location
return patrol_waypoints[0]
return nav_agent.get_next_location()
func get_next_patrol_target() -> Vector2:
var waypoint_count = patrol_waypoints.size()
for wp in patrol_waypoints:
if next_waypoint == wp:
patrol_waypoint_index = patrol_waypoint_index + 1 if patrol_waypoint_index < waypoint_count - 1 else 0
return patrol_waypoints[patrol_waypoint_index]
patrol_waypoint_index = 0
return patrol_waypoints[0]
var waypoint_count = patrol_waypoints.size()
for wp in patrol_waypoints:
if next_waypoint == wp:
patrol_waypoint_index = patrol_waypoint_index + 1 if patrol_waypoint_index < waypoint_count - 1 else 0
return patrol_waypoints[patrol_waypoint_index]
patrol_waypoint_index = 0
return patrol_waypoints[0]
func hunting() -> Vector2:
slow_down_factor = 1.0
if(detect_timer > 0.33):
detect_player()
detect_timer = 0.0
next_waypoint = players[0].global_position - Vector2(0,9)
return nav_agent.get_next_location()
slow_down_factor = 1.0
if(detect_timer > 0.33):
detect_player()
detect_timer = 0.0
next_waypoint = players[0].global_position - Vector2(0,9)
return nav_agent.get_next_location()
func detect_player() -> void:
var player
if(players.empty()):
# print("no player found")
return
player = players[0]
#TODO Depends on height of blobby sprite since blobbys bottom and not his middle is on y=0
vision_raycast.cast_to = (player.global_position - global_position - Vector2(0,9)).normalized() * 16 * vision_distance
var ray_angle_to_facing = vision_raycast.cast_to.angle_to(orientation.cast_to)
vision_raycast.force_raycast_update()
var collider = vision_raycast.get_collider()
if(abs(ray_angle_to_facing) < PI/2-deg2rad(blindspot_angle) && collider != null && collider.is_in_group("player")):
target_lost_timer.stop()
target = collider
# print("target found")
elif(target != null && target_lost_timer.is_stopped()):
target_lost_timer.start(loose_target_seconds)
var player
if(players.empty()):
# print("no player found")
return
player = players[0]
#TODO Depends on height of blobby sprite since blobbys bottom and not his middle is on y=0
vision_raycast.cast_to = (player.global_position - global_position - Vector2(0,9)).normalized() * 16 * vision_distance
var ray_angle_to_facing = vision_raycast.cast_to.angle_to(orientation.cast_to)
vision_raycast.force_raycast_update()
var collider = vision_raycast.get_collider()
if(abs(ray_angle_to_facing) < PI/2-deg2rad(blindspot_angle) && collider != null && collider.is_in_group("player")):
target_lost_timer.stop()
target = collider
# print("target found")
elif(target != null && target_lost_timer.is_stopped()):
target_lost_timer.start(loose_target_seconds)
func execute_movement(delta: float) -> void:
detect_timer += delta
var next_direction = lerp(previous_direction, path_direction - global_position, 0.5)
previous_direction = next_direction
orientation.cast_to = Vector2(sign(next_direction.x),0)*50
var avoidance_obstacle_distance = average_collision_vector(avoidance_raycasts)
next_direction = next_direction.normalized() + avoidance_obstacle_distance.rotated(PI).normalized()
# TODO Make parameters more tunable
velocity = move_and_slide(PhysicsFunc.two_step_euler_vec(velocity, next_direction.normalized() * acceleration * slow_down_factor, weight, delta)
,FLOOR_NORMAL, false, 4, 0.785398,false)
velocity = velocity/max((velocity.length()/(max_speed*slow_down_factor)),1)
detect_timer += delta
var next_direction = lerp(previous_direction, path_direction - global_position, 0.5)
previous_direction = next_direction
orientation.cast_to = Vector2(sign(next_direction.x),0)*50
var avoidance_obstacle_distance = average_collision_vector(avoidance_raycasts)
next_direction = next_direction.normalized() + avoidance_obstacle_distance.rotated(PI).normalized()
# TODO Make parameters more tunable
velocity = move_and_slide(PhysicsFunc.two_step_euler_vec(velocity, next_direction.normalized() * acceleration * slow_down_factor, weight, delta)
,FLOOR_NORMAL, false, 4, 0.785398,false)
velocity = velocity/max((velocity.length()/(max_speed*slow_down_factor)),1)
func average_collision_vector(var raycasts: Array) -> Vector2:
var total_distances = Vector2()
for raycast in raycasts:
if !raycast.is_colliding():
continue
var collision_point = self.to_local(raycast.get_collision_point())
total_distances += collision_point
return total_distances/raycasts.size()
var total_distances = Vector2()
for raycast in raycasts:
if !raycast.is_colliding():
continue
var collision_point = self.to_local(raycast.get_collision_point())
total_distances += collision_point
return total_distances/raycasts.size()
func spawn_avoidance_raycasts(var raycount: int, var length: float = 24) -> void:
var direction: float = 0
while direction <= 2*PI:
var raycast: RayCast2D = RayCast2D.new()
raycast.enabled = true
raycast.exclude_parent = true
raycast.collide_with_areas = true
raycast.collide_with_bodies = true
# Layers 4, 5 & 6
raycast.collision_mask = 56
raycast.cast_to = Vector2(length, 0).rotated(direction)
add_child(raycast)
avoidance_raycasts.append(raycast)
direction += (2*PI)/raycount
var direction: float = 0
while direction <= 2*PI:
var raycast: RayCast2D = RayCast2D.new()
raycast.enabled = true
raycast.exclude_parent = true
raycast.collide_with_areas = true
raycast.collide_with_bodies = true
# Layers 4, 5 & 6
raycast.collision_mask = 56
raycast.cast_to = Vector2(length, 0).rotated(direction)
add_child(raycast)
avoidance_raycasts.append(raycast)
direction += (2*PI)/raycount
# Checks the feeler ray for collisions and returns collision or null
func check_feeler(v: Vector2, _offset = Vector2(0,0)) -> Object:
var prev_position = feeler_raycast.position
feeler_raycast.position += _offset
feeler_raycast.cast_to = v
feeler_raycast.force_raycast_update()
feeler_raycast.position = prev_position
return feeler_raycast.get_collider()
var prev_position = feeler_raycast.position
feeler_raycast.position += _offset
feeler_raycast.cast_to = v
feeler_raycast.force_raycast_update()
feeler_raycast.position = prev_position
return feeler_raycast.get_collider()
func lose_target() -> void:
# print("flyer target lost")
target = null
# print("flyer target lost")
target = null
func update_navigation() -> void:
nav_agent.set_target_location(next_waypoint)
nav_agent.set_target_location(next_waypoint)
func die() -> void:
levelState.kills += 1
queue_free()
levelState.kills += 1
queue_free()
func get_facing_direction() -> float:
return orientation.cast_to.x
return orientation.cast_to.x

View File

@ -187,10 +187,10 @@ graph_offset = Vector2( -333, -104 )
extents = Vector2( 10, 7.5 )
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 15, 5.12039 )
extents = Vector2( 11.4286, 5.12039 )
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 18.2143, 14.3338 )
[sub_resource type="RectangleShape2D" id=52]
extents = Vector2( 15.7143, 12.1429 )
[node name="Flyer" type="KinematicBody2D" groups=["frogfood", "harmful"]]
collision_layer = 258
@ -225,7 +225,6 @@ unique_name_in_owner = true
scale = Vector2( -1, 1 )
texture = ExtResource( 4 )
hframes = 2
frame = 1
[node name="AnimationPlayer" type="AnimationPlayer" parent="FlyerSprite"]
anims/RESET = SubResource( 33 )
@ -277,7 +276,6 @@ bias = 0.108
softness = 0.1
[node name="StompDetector" type="Area2D" parent="." groups=["weakpoint"]]
visible = false
modulate = Color( 0, 0.0392157, 1, 1 )
position = Vector2( 0, -1.90735e-06 )
scale = Vector2( 0.7, 0.7 )
@ -285,18 +283,19 @@ collision_layer = 2
input_pickable = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="StompDetector"]
position = Vector2( -4.76837e-07, 1.56134 )
position = Vector2( 6.81196e-07, 1.56134 )
shape = SubResource( 2 )
[node name="EnemySkin" type="Area2D" parent="."]
process_priority = -1
visible = false
[node name="DangerousBlockArea" type="Node2D" parent="."]
scale = Vector2( 0.7, 0.7 )
collision_layer = 2
collision_mask = 126
[node name="CollisionPolygon2D" type="CollisionShape2D" parent="EnemySkin"]
shape = SubResource( 3 )
[node name="Area2D" type="Area2D" parent="DangerousBlockArea" groups=["harmful"]]
collision_layer = 8
collision_mask = 3
[node name="CollisionShape2D" type="CollisionShape2D" parent="DangerousBlockArea/Area2D"]
position = Vector2( 5.10897e-07, -0.714285 )
shape = SubResource( 52 )
[node name="PatrolPath" type="Node2D" parent="."]

View File

@ -2,17 +2,17 @@ extends Enemy
func _ready() -> void:
set_physics_process(false)
velocity.x = -40
set_physics_process(false)
velocity.x = -40
func _physics_process(delta: float) -> void:
velocity.y += _gravity * delta
if is_on_wall() or is_at_ledge():
velocity.x *= -1.0
velocity.y = move_and_slide(velocity, FLOOR_NORMAL).y
velocity.y += _gravity * delta
if is_on_wall() or is_at_ledge():
velocity.x *= -1.0
velocity.y = move_and_slide(velocity, FLOOR_NORMAL).y
func is_at_ledge():
for raycast in $LedgeDetectorRays.get_children():
if !raycast.is_colliding():
return true
return false
for raycast in $LedgeDetectorRays.get_children():
if !raycast.is_colliding():
return true
return false

View File

@ -2,21 +2,21 @@ extends Enemy
func _ready() -> void:
set_physics_process(false)
velocity.x = -30
set_physics_process(false)
velocity.x = -30
# TODO adapt to groups
func _physics_process(delta: float) -> void:
velocity.y += _gravity * delta
if is_on_wall() or !is_safe_drop():
velocity.x *= -1.0
velocity.y = move_and_slide(velocity, FLOOR_NORMAL).y
velocity.y += _gravity * delta
if is_on_wall() or !is_safe_drop():
velocity.x *= -1.0
velocity.y = move_and_slide(velocity, FLOOR_NORMAL).y
func is_safe_drop():
for raycast in $LedgeDetectorRays.get_children():
if raycast.is_colliding():
var collider = raycast.get_collider()
if collider.is_in_group("harmful"):
return false
return true
for raycast in $LedgeDetectorRays.get_children():
if raycast.is_colliding():
var collider = raycast.get_collider()
if collider.is_in_group("harmful"):
return false
return true

View File

@ -42,10 +42,10 @@ unique_name_in_owner = true
process_mode = 1
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
frame = 2
frame = 11
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
frame = 1
frame = 10
[node name="Blobby" parent="." instance=ExtResource( 7 )]
unique_name_in_owner = true

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=19 format=2]
[gd_scene load_steps=20 format=2]
[ext_resource path="res://assets/environment/decor/platform-plants.png" type="Texture" id=1]
[ext_resource path="res://src/Contraptions/Triggers/ElevatorButton.tscn" type="PackedScene" id=2]
@ -15,6 +15,7 @@
[ext_resource path="res://src/Environment/DropThroughPlatforms.tres" type="TileSet" id=13]
[ext_resource path="res://src/Platforms/FlyingPlatform.tscn" type="PackedScene" id=14]
[ext_resource path="res://src/Actors/Enemies/Beings/Caterpillar.tscn" type="PackedScene" id=15]
[ext_resource path="res://src/BenefitialObjects/Coin.tscn" type="PackedScene" id=16]
[sub_resource type="AnimationNodeStateMachinePlayback" id=4]
@ -80,10 +81,10 @@ wait_time = 20.0
unique_name_in_owner = true
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
frame = 2
frame = 3
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
frame = 1
frame = 2
[node name="Blobby" parent="." instance=ExtResource( 10 )]
unique_name_in_owner = true
@ -179,6 +180,12 @@ scale = Vector2( 0.75, 1 )
autoplay = "Path"
anims/Path = SubResource( 6 )
[node name="Coin" parent="." instance=ExtResource( 16 )]
position = Vector2( 383, -31 )
[node name="Coin2" parent="." instance=ExtResource( 16 )]
position = Vector2( 496, -337 )
[connection signal="body_exited" from="Blobby/BlobbySkin" to="Blobby" method="_on_BlobbySkin_body_exited"]
[editable path="SignalManager"]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -44,10 +44,10 @@ wait_time = 20.0
unique_name_in_owner = true
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
frame = 2
frame = 6
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
frame = 6
frame = 10
[node name="Blobby" parent="." instance=ExtResource( 15 )]
unique_name_in_owner = true

View File

@ -89,10 +89,10 @@ wait_time = 20.0
[node name="BlobbyCam" parent="." instance=ExtResource( 6 )]
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
frame = 7
frame = 1
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
frame = 12
frame = 6
[node name="Blobby" parent="." instance=ExtResource( 12 )]
unique_name_in_owner = true

View File

@ -1,6 +1,14 @@
extends Node2D
extends Node
onready var slide_friction = 2
onready var tween_values = []
export var x_target = 0
export var y_target = 0
export var speed = 32
var time
# Declare member variables here. Examples:
# var a: int = 2
# var b: String = "text"
@ -8,9 +16,20 @@ onready var slide_friction = 2
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
$anim.play("Horizontal")
var start = Vector2(0,0)
var end = Vector2(x_target, y_target)
tween_values.append(start)
tween_values.append(end)
time = start.distance_to(end)/speed
_start_tween()
func _start_tween():
$FlyTween.interpolate_property($PlatformBody, "position",
tween_values[0], tween_values[1], time,
Tween.TRANS_QUAD, Tween.EASE_IN_OUT)
$FlyTween.start()
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta: float) -> void:
# pass
func _on_FlyTween_tween_completed(object: Object, key: NodePath) -> void:
tween_values.invert()
_start_tween()

View File

@ -1,59 +1,27 @@
[gd_scene load_steps=5 format=2]
[gd_scene load_steps=3 format=2]
[ext_resource path="res://src/Platforms/FlyingPlatform.gd" type="Script" id=1]
[ext_resource path="res://assets/contraption/floating_platform_test.png" type="Texture" id=2]
[sub_resource type="Animation" id=3]
resource_name = "Path"
length = 6.0
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("KinematicBody2D:position")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 3 ),
"transitions": PoolRealArray( 1, 0.965936 ),
"update": 0,
"values": [ Vector2( 0, 0 ), Vector2( -48, -40 ) ]
}
[sub_resource type="Animation" id=4]
length = 0.001
tracks/0/type = "value"
tracks/0/path = NodePath("KinematicBody2D:position")
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": [ Vector2( 0, 0 ) ]
}
[node name="FlyingPlatform" type="Node2D"]
script = ExtResource( 1 )
[node name="anim" type="AnimationPlayer" parent="."]
playback_process_mode = 0
anims/Path = SubResource( 3 )
anims/RESET = SubResource( 4 )
[node name="KinematicBody2D" type="KinematicBody2D" parent="."]
collision_layer = 8
[node name="PlatformBody" type="KinematicBody2D" parent="."]
collision_layer = 16
collision_mask = 0
motion/sync_to_physics = true
[node name="Sprite" type="Sprite" parent="KinematicBody2D"]
[node name="Sprite" type="Sprite" parent="PlatformBody"]
position = Vector2( 0, 8 )
texture = ExtResource( 2 )
vframes = 8
frame = 1
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="KinematicBody2D"]
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="PlatformBody"]
position = Vector2( 0, 4 )
scale = Vector2( 4, 0.4 )
polygon = PoolVector2Array( -10, -10, 10, -10, 9.5, 0, 9.25, 5, -9.25, 5, -9.5, 0 )
[node name="FlyTween" type="Tween" parent="."]
[connection signal="tween_completed" from="FlyTween" to="." method="_on_FlyTween_tween_completed"]