summaryrefslogtreecommitdiffstats
path: root/PatrolEnemy.gd
blob: 602df8f5c032730aa7908bbb4e3c888c36f7d8a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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

	velocity.y = clamp(velocity.y, -INF, GlobalData.MAX_FALL_SPEED)
	move_and_slide(velocity, Vector2.UP)