tried some stuff with getting the region right... not working
This commit is contained in:
@@ -2,7 +2,8 @@ extends CharacterBody2D
|
|||||||
|
|
||||||
@export var unitData = {
|
@export var unitData = {
|
||||||
"MoveRange": 5,
|
"MoveRange": 5,
|
||||||
"MoveRangeV": Vector2i(5, 5),
|
"MoveRangeVi": Vector2i(5, 5),
|
||||||
|
"MoveRangeV": Vector2(5, 5),
|
||||||
"Speed": 400.0
|
"Speed": 400.0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +64,7 @@ func _physics_process(delta: float) -> void:
|
|||||||
currentCell = pos_to_cell(global_position)
|
currentCell = pos_to_cell(global_position)
|
||||||
$PathPrev.points = [];
|
$PathPrev.points = [];
|
||||||
moving = false; MoveFinished.emit();
|
moving = false; MoveFinished.emit();
|
||||||
MapGlobal.SetRegion(calculateMovementRegion(), unitData["MoveRangeV"])
|
MapGlobal.SetRegion(calculateMovementRegion(), -unitData["MoveRangeVi"])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
var direction = (movePts[currentPoint+1] - movePts[currentPoint]).normalized()
|
var direction = (movePts[currentPoint+1] - movePts[currentPoint]).normalized()
|
||||||
@@ -80,6 +81,5 @@ func selectUnit(cell: Vector2i):
|
|||||||
selected = false
|
selected = false
|
||||||
|
|
||||||
func calculateMovementRegion():
|
func calculateMovementRegion():
|
||||||
var region := Rect2i(pos_to_cell(global_position), Vector2i(unitData["MoveRange"], unitData["MoveRange"]))
|
var region := Rect2i(pos_to_cell(global_position - unitData["MoveRangeV"]), unitData["MoveRangeVi"] * 2)
|
||||||
region.set_center
|
|
||||||
return region
|
return region
|
||||||
|
|||||||
Reference in New Issue
Block a user