poorly coded enemies
This commit is contained in:
15
Actors/Enemy.gd
Normal file
15
Actors/Enemy.gd
Normal file
@@ -0,0 +1,15 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
var velocity = Vector2(0,-100)
|
||||
var push = 2500
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
move_and_slide(velocity, Vector2.UP, false, 4, PI/4, false)
|
||||
for index in get_slide_count():
|
||||
var collision = get_slide_collision(index)
|
||||
if collision.collider.is_in_group("Balls"):
|
||||
print("balls")
|
||||
collision.collider.apply_central_impulse(collision.normal * push)
|
18
Actors/Enemy.tscn
Normal file
18
Actors/Enemy.tscn
Normal file
@@ -0,0 +1,18 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://icon.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Actors/Enemy.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
radius = 26.0
|
||||
|
||||
[node name="Enemy" type="KinematicBody2D"]
|
||||
collision_layer = 4
|
||||
collision_mask = 4
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 1 )
|
Reference in New Issue
Block a user