Add basic npc entity script.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
extends CharacterBody3D
|
||||
class_name OverworldEntity
|
||||
class_name OverworldEntity extends CharacterBody3D
|
||||
|
||||
const PauseSystem = preload("res://scripts/System/PauseSystem.gd")
|
||||
|
||||
@@ -14,7 +13,11 @@ var speed:float = 150;
|
||||
var friction:float = 8.5;
|
||||
var gravity:float = 30;
|
||||
|
||||
var direction = Direction.SOUTH;
|
||||
@export var direction = Direction.SOUTH:
|
||||
set(newDirection):
|
||||
direction = newDirection;
|
||||
_updateMaterial();
|
||||
|
||||
var meshInstance:MeshInstance3D;
|
||||
var underFootTile:int = -1;
|
||||
var underFootPosition:Vector3;
|
||||
@@ -22,6 +25,14 @@ var underFootPosition:Vector3;
|
||||
var withinMapBounds:MapBounds;
|
||||
var withinBoundsLastFrame:bool = true;
|
||||
|
||||
func _updateMaterial():
|
||||
if !meshInstance:
|
||||
return
|
||||
var material:ShaderMaterial = meshInstance.get_surface_override_material(0)
|
||||
if !material:
|
||||
return
|
||||
material.set_shader_parameter("direction", direction)
|
||||
|
||||
func getSystems() -> Systems:
|
||||
return get_tree().current_scene.get_node("Systems") as Systems;
|
||||
|
||||
@@ -128,6 +139,7 @@ func _updateTileData() -> void:
|
||||
func _ready() -> void:
|
||||
meshInstance = get_node("MeshInstance3D")
|
||||
_updateTileData();
|
||||
_updateMaterial();
|
||||
pass
|
||||
|
||||
func _process(delta:float) -> void:
|
||||
@@ -144,10 +156,6 @@ func _process(delta:float) -> void:
|
||||
|
||||
# Update logic
|
||||
updateOverworldLogic(delta)
|
||||
|
||||
# Set shader direction.
|
||||
var material:ShaderMaterial = meshInstance.get_surface_override_material(0)
|
||||
material.set_shader_parameter("direction", direction)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if isPaused():
|
||||
|
Reference in New Issue
Block a user