1
0
Fork 0

Fixed crawling enemy

This commit is contained in:
Felipe M 2021-05-18 20:17:08 +02:00
parent f6758e1dba
commit b7b4d03fda
Signed by: fmartingr
GPG Key ID: 716BC147715E716F
4 changed files with 17 additions and 12 deletions

View File

@ -19,7 +19,7 @@ func _physics_process(delta):
floorCast.rotation_degrees = -MAX_SPEED * 10 * WALKING_DIRECTION * delta
if floorCast.is_colliding():
global_position = floorCast.get_collision_point()
var normal = wallCast.get_collision_normal()
var normal = floorCast.get_collision_normal()
rotation = normal.rotated(deg2rad(90)).angle()
else:
rotation_degrees += 20 * WALKING_DIRECTION

View File

@ -4,7 +4,7 @@
[ext_resource path="res://Assets/Enemies/CrawlingEnemy.png" type="Texture" id=2]
[ext_resource path="res://Scenes/Enemies/CrawlingEnemy.gd" type="Script" id=3]
[sub_resource type="Animation" id=3]
[sub_resource type="Animation" id=1]
resource_name = "Animate"
length = 0.8
loop = true
@ -18,13 +18,13 @@ tracks/0/keys = {
"times": PoolRealArray( 0, 0.2, 0.4, 0.6 ),
"transitions": PoolRealArray( 1, 1, 1, 1 ),
"update": 1,
"values": [ 0, 1, 1, 1 ]
"values": [ 0, 1, 2, 3 ]
}
[sub_resource type="RectangleShape2D" id=1]
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 7, 3 )
[sub_resource type="RectangleShape2D" id=2]
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 5, 2 )
[node name="CrawlingEnemy" instance=ExtResource( 1 )]
@ -34,24 +34,24 @@ script = ExtResource( 3 )
position = Vector2( 0, -8 )
texture = ExtResource( 2 )
hframes = 4
frame = 1
frame = 3
[node name="AnimationPlayer" parent="." index="2"]
autoplay = "Animate"
anims/Animate = SubResource( 3 )
anims/Animate = SubResource( 1 )
[node name="Collider" parent="Hurtbox" index="0"]
position = Vector2( 0, -3 )
shape = SubResource( 1 )
shape = SubResource( 2 )
[node name="Collider" parent="Hitbox" index="0"]
position = Vector2( 0, -2 )
shape = SubResource( 2 )
shape = SubResource( 3 )
[node name="FloorCast" type="RayCast2D" parent="." index="6"]
position = Vector2( 0, -4 )
enabled = true
cast_to = Vector2( 0, 4 )
cast_to = Vector2( 0, 8 )
collision_mask = 2
[node name="WallCast" type="RayCast2D" parent="." index="7"]
@ -61,5 +61,4 @@ cast_to = Vector2( 4, 0 )
collision_mask = 2
[editable path="Hurtbox"]
[editable path="Hitbox"]

View File

@ -43,7 +43,12 @@ position = Vector2( 224, 88 )
[node name="PlantEnemy" parent="." instance=ExtResource( 9 )]
position = Vector2( 136, 128 )
[node name="PlantEnemy2" parent="." instance=ExtResource( 9 )]
position = Vector2( 402.842, 16 )
rotation = 3.14159
[node name="CrawlingEnemy" parent="." instance=ExtResource( 10 )]
position = Vector2( 72, 160 )
[editable path="Player"]
[editable path="Player/Hurtbox"]

View File

@ -120,5 +120,6 @@ pause={
[rendering]
quality/2d/use_pixel_snap=true
2d/snapping/use_gpu_pixel_snap=true
environment/default_environment="res://default_env.tres"
quality/2d/use_pixel_snap=true