Almost fixed entities

This commit is contained in:
2025-05-12 21:00:13 -05:00
parent 828ff03e56
commit a575b8a47d
13 changed files with 158 additions and 79 deletions

View File

@@ -18,6 +18,8 @@ enum Direction {
direction = newDirection;
_updateMaterial();
@export var characterBody:CharacterBody3D = null
func _ready() -> void:
_updateMaterial();
@@ -63,16 +65,19 @@ func updateDirectionFromMovement(movement:Vector2) -> void:
elif (movement.y < 0):
direction = Direction.NORTH;
# func getDirectionToFace(position:Vector3) -> Direction:
# var diff = position - self.position;
# if abs(diff.x) > abs(diff.z):
# if diff.x > 0:
# return Direction.EAST;
# else:
# return Direction.WEST;
# else:
# if diff.z > 0:
# return Direction.SOUTH;
# else:
# return Direction.NORTH;
# return Direction.SOUTH;
func getDirectionToFace(position:Vector3) -> Direction:
if !characterBody:
return Direction.SOUTH;
var diff = position - characterBody.position;
if abs(diff.x) > abs(diff.z):
if diff.x > 0:
return Direction.EAST;
else:
return Direction.WEST;
else:
if diff.z > 0:
return Direction.SOUTH;
else:
return Direction.NORTH;
return Direction.SOUTH;