CrawlingEnemy, PlantEnemy
This commit is contained in:
parent
930ff3e2bb
commit
f6758e1dba
6 changed files with 233 additions and 4 deletions
25
metroidvania/Scenes/Enemies/CrawlingEnemy.gd
Normal file
25
metroidvania/Scenes/Enemies/CrawlingEnemy.gd
Normal file
|
@ -0,0 +1,25 @@
|
|||
extends "res://Scenes/Enemies/Enemy.gd"
|
||||
|
||||
enum DIRECTION {LEFT = -1, RIGHT = 1}
|
||||
|
||||
export (DIRECTION) var WALKING_DIRECTION = DIRECTION.RIGHT
|
||||
|
||||
onready var floorCast = $FloorCast
|
||||
onready var wallCast = $WallCast
|
||||
|
||||
func _ready():
|
||||
wallCast.cast_to.x *= WALKING_DIRECTION
|
||||
|
||||
func _physics_process(delta):
|
||||
if wallCast.is_colliding():
|
||||
global_position = wallCast.get_collision_point()
|
||||
var normal = wallCast.get_collision_normal()
|
||||
rotation = normal.rotated(deg2rad(90)).angle()
|
||||
else:
|
||||
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()
|
||||
rotation = normal.rotated(deg2rad(90)).angle()
|
||||
else:
|
||||
rotation_degrees += 20 * WALKING_DIRECTION
|
Loading…
Add table
Add a link
Reference in a new issue