diff options
| author | Jan Tuomi <jan.tuomi@valuemotive.com> | 2022-08-10 00:23:36 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan.tuomi@valuemotive.com> | 2022-08-10 00:23:36 +0300 |
| commit | f3cc4f82624b21dafa19515b69c66a3c8f4fe248 (patch) | |
| tree | 8781f4bf0356b28e49c31195776980121a4707df /PatrolEnemy.gd | |
| parent | 2d888d00efba0314ac6357f2dbccd0ad01173023 (diff) | |
Add enemy
Diffstat (limited to 'PatrolEnemy.gd')
| -rw-r--r-- | PatrolEnemy.gd | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/PatrolEnemy.gd b/PatrolEnemy.gd new file mode 100644 index 0000000..b3d02e2 --- /dev/null +++ b/PatrolEnemy.gd @@ -0,0 +1,20 @@ +extends KinematicBody2D + +export(float) var WALK_SPEED: float = 100 + +var velocity: Vector2 = WALK_SPEED * Vector2.LEFT + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + +func _physics_process(delta): + velocity.y += delta * GlobalData.GRAVITY + + if $RayCastWall.is_colliding(): + scale.x = -scale.x + velocity.x = -velocity.x + print(scale, velocity) + + velocity.y = clamp(velocity.y, -INF, GlobalData.MAX_FALL_SPEED) + move_and_slide(velocity, Vector2.UP) |
