Skip to content

Commit

Permalink
fix: don't apply gravity to wall crawlers
Browse files Browse the repository at this point in the history
Wall-crawlers no longer have gravity applied (in idle and run states).
this fixes crawlers sticking to the ceiling and wall starting positions,
tho they need to be overlapping/_very_ close to the walls for
is_on_wall/ceiling/etc to detect the wall - could be better to use a
raycast to find the nearest wall and move toward it.
  • Loading branch information
russmatney committed May 28, 2024
1 parent 3bc3f03 commit ce4b2e4
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 20 deletions.
23 changes: 14 additions & 9 deletions src/dino/enemies/EnemyGym.tscn

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/dino/enemies/SSEnemy.gd
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ func _ready():

func _physics_process(_delta):
if crawl_on_side == null and should_crawl_on_walls:
# calling move_and_slide to detect a side a frame earlier
move_and_slide()
if is_on_wall_only():
crawl_on_side = get_wall_normal()
elif is_on_floor_only():
Expand Down Expand Up @@ -235,7 +237,7 @@ func orient_to_wall(side):
var hitbox_bodies = []

func _on_hitbox_body_entered(body):
if is_dead:
if is_dead or ("is_dead" in body and body.is_dead):
return
if body.is_in_group("player"):
hitbox_bodies.append(body)
Expand All @@ -244,8 +246,6 @@ func _on_hitbox_body_entered(body):
if should_hurt_to_touch and machine.can_bump():
body.take_hit({body=self, type="bump"})

# TODO kick is specific, do we want a generic attack?
# should probably do this from each state's physics_process()
if should_kick_player and machine.can_attack():
# this body isn't used at the moment
machine.transit("Kick", {body=body})
Expand Down
7 changes: 3 additions & 4 deletions src/dino/enemies/blobs/Blob.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
[ext_resource type="PackedScene" path="res://src/effects/SkullParticles.tscn" id="6_fsp6w"]
[ext_resource type="Texture2D" uid="uid://bpauup22464bb" path="res://addons/core/assets/lights/light1_nobg_sheet.png" id="7_3c06x"]

[sub_resource type="RectangleShape2D" id="RectangleShape2D_5mmx1"]
size = Vector2(24, 26)
[sub_resource type="CircleShape2D" id="CircleShape2D_7q5cw"]

[sub_resource type="AtlasTexture" id="AtlasTexture_uftm3"]
atlas = ExtResource("2_1fu8s")
Expand Down Expand Up @@ -169,7 +168,7 @@ animations = [{
}]

[sub_resource type="CircleShape2D" id="CircleShape2D_436mn"]
radius = 14.0
radius = 16.0

[sub_resource type="CircleShape2D" id="CircleShape2D_jiqhh"]
radius = 74.2428
Expand All @@ -182,7 +181,7 @@ should_hurt_to_touch = true

[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, 1)
shape = SubResource("RectangleShape2D_5mmx1")
shape = SubResource("CircleShape2D_7q5cw")

[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
texture_filter = 1
Expand Down
36 changes: 36 additions & 0 deletions src/dino/enemies/shootyCrawly/ShootyCrawlyGym.tscn

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/dino/enemies/sidescroller_machine/Idle.gd
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ func enter(ctx={}):
## process #####################################################################

func physics_process(delta):
if not actor.is_on_floor():
if actor.should_crawl_on_walls:
# wall-crawlers shouldn't fall in idle (stay on the wall)
pass
elif not actor.is_on_floor():
actor.velocity.y += actor.gravity * delta

if stop:
Expand Down
5 changes: 4 additions & 1 deletion src/dino/enemies/sidescroller_machine/Run.gd
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ func physics_process(delta):
machine.transit("Fire")
return

if not actor.is_on_floor():
if actor.should_crawl_on_walls:
# wall-crawlers shouldn't fall (stay on the wall)
pass
elif not actor.is_on_floor():
actor.velocity.y += actor.gravity * delta

if actor.move_vector.x > 0:
Expand Down
4 changes: 2 additions & 2 deletions src/dino/enemies/soldiers/Soldier.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ knockback_velocity_horizontal = 20.0
dying_velocity = -400.0
initial_health = 3
should_see_player = true
should_hop = null
show_debug = null
should_kick_player = true
should_hurt_to_touch = true

[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_5cd88")
Expand Down

0 comments on commit ce4b2e4

Please sign in to comment.