June 2018
Beginner to intermediate
298 pages
7h 38m
English
Hopefully, you're seeing how inheritance works by now. You'll create the Enemy scene using the same procedure. Make a new scene inheriting from Character.tscn and name it Enemy. Drag the mob spritesheet, res://assets/slime.png, to the Sprite's Texture.
In the Collision section of the Inspector, set the Layer and Mask properties. Layer should be set to enemies, while Mask should show walls and player. Click on the Node tab, and add the enemy to the enemies group.
As you did with the Player, remove the existing script and attach a new script inheriting from Character.gd:
extends "res://character/Character.gd"func _ready(): can_move = false facing = moves.keys()[randi() % 4] yield(get_tree().create_timer(0.5), 'timeout') can_move ...
Read now
Unlock full access