Skip to content

Commit

Permalink
fix: camera commands to use time instead of speed (#509)
Browse files Browse the repository at this point in the history
Co-authored-by: Balloonpopper <[email protected]>
  • Loading branch information
balloonpopper and Balloonpopper authored Feb 25, 2022
1 parent c173882 commit d3f1b8b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# `camera_set_pos speed x y`
# `camera_set_pos time x y`
#
# Moves the camera to the given position.
#
# **Parameters**
#
# - *speed*: Number of seconds the transition should take
# - *time*: Number of seconds the transition should take
# - *x*: Target X coordinate
# - "y*: Target Y coordinate
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# `camera_set_target speed object`
# `camera_set_target time object`
#
# Configures the camera to follow the specified target `object`
#
# **Parameters**
#
# - *speed*: Number of seconds the transition should take
# - *time*: Number of seconds the transition should take
# - *object*: Global ID of the target object
#
# For more details see: https://docs.escoria-framework.org/camera
Expand Down
12 changes: 4 additions & 8 deletions addons/escoria-core/game/scenes/camera_player/esc_camera.gd
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,17 @@ func set_drag_margin_enabled(p_dm_h_enabled, p_dm_v_enabled):
#
# #### Parameters
# - p_target: Object to target
# - p_speed: Number of seconds for the camera to reach the target
func set_target(p_target, p_speed : float = 0.0):
var speed = p_speed

# - p_time: Number of seconds for the camera to reach the target
func set_target(p_target, p_time : float = 0.0):
_resolve_target_and_zoom(p_target)

escoria.logger.info(
"Current camera position = %s " % str(self.global_position)
)

if speed == 0.0:
if p_time == 0.0:
self.global_position = _target
else:
var time = self.global_position.distance_to(_target) / speed

if _tween.is_active():
escoria.logger.report_warnings(
"esc_camera.gd:set_target()",
Expand All @@ -119,7 +115,7 @@ func set_target(p_target, p_speed : float = 0.0):
"global_position",
self.global_position,
_target,
time,
p_time,
Tween.TRANS_LINEAR,
Tween.EASE_IN_OUT
)
Expand Down

0 comments on commit d3f1b8b

Please sign in to comment.