Almost fixed entities
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user