replace position with global_position in some places
This commit is contained in:
@@ -37,7 +37,7 @@ func _process(delta: float) -> void:
|
||||
|
||||
var offset_direction := Vector3.BACK.rotated(Vector3.RIGHT, rotation.x)
|
||||
var offset := offset_direction * distance
|
||||
position = target_position + offset
|
||||
global_position = target_position + offset
|
||||
|
||||
DebugDraw.marker(target_position, 0.05)
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ func _input(event: InputEvent) -> void:
|
||||
func _handle_frustrum_shape() -> void:
|
||||
var viewport_size := get_viewport().get_visible_rect().size
|
||||
|
||||
var origin := camera.position
|
||||
var origin := camera.global_position
|
||||
var far := camera.far - 1
|
||||
var corner_1 := camera.project_position(Vector2.ZERO, far)
|
||||
var corner_2 := camera.project_position(Vector2(viewport_size.x, 0), far)
|
||||
@@ -95,7 +95,7 @@ func _handle_unit_selection() -> void:
|
||||
var rect_abs := selection_rect.abs()
|
||||
|
||||
for unit: Node3D in visible_units.values():
|
||||
var point := camera.unproject_position(unit.position)
|
||||
var point := camera.unproject_position(unit.global_position)
|
||||
if unit is TestUnit:
|
||||
(unit as TestUnit).set_selected(rect_abs.has_point(point))
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ func _set_target_click(mouse_pos: Vector2) -> void:
|
||||
|
||||
|
||||
func _click_raycast(mouse_pos: Vector2) -> Vector3:
|
||||
var from := camera.position
|
||||
var from := camera.global_position
|
||||
var to := camera.project_ray_normal(mouse_pos)
|
||||
return ground_plane.intersects_ray(from, to)
|
||||
|
||||
@@ -63,14 +63,14 @@ func _navigate() -> void:
|
||||
|
||||
var next_pos := nav_agent.get_next_path_position()
|
||||
|
||||
var direction := position.direction_to(next_pos)
|
||||
var direction := global_position.direction_to(next_pos)
|
||||
var new_velocity := direction * SPEED
|
||||
nav_agent.set_velocity(new_velocity)
|
||||
|
||||
|
||||
func _animate() -> void:
|
||||
if velocity.length() > 0.1:
|
||||
look_at(position + velocity, Vector3.UP, true)
|
||||
look_at(global_position + velocity, Vector3.UP, true)
|
||||
animation_player.play('walk')
|
||||
else:
|
||||
animation_player.play('idle')
|
||||
|
||||
Reference in New Issue
Block a user