Skip to content

Commit

Permalink
chore: update phantom camera
Browse files Browse the repository at this point in the history
  • Loading branch information
russmatney committed Jan 22, 2024
1 parent df9aaba commit cd4f2f1
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/PhantomCamera2DSprite.png-6bf2b757da36375026c
[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/inventory_container.png-12241277f279bfc4bf7d5
[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/level_spritesheet.png-26a44dd21a040a5480d5ccb
[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/sign_prompt.png-18d451127e1cd1a16367acd23cec4
[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
Expand Down
2 changes: 1 addition & 1 deletion addons/phantom_camera/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
name="Phantom Camera"
description="Control the movement and dynamically tween 2D & 3D cameras positions. Built for Godot 4. Inspired by Cinemachine."
author="Marcus Skov"
version="0.6.2.1"
version="0.6.2.2"
script="plugin.gd"
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,8 @@ func _enter_tree() -> void:
update_limit_all_sides()

func _exit_tree() -> void:
if Properties.pcam_host_owner:
Properties.pcam_host_owner.pcam_removed_from_scene(self)
if _has_valid_pcam_owner():
get_pcam_host_owner().pcam_removed_from_scene(self)

Properties.pcam_exit_tree(self)

Expand Down
16 changes: 14 additions & 2 deletions addons/phantom_camera/scripts/phantom_camera/phantom_camera_3D.gd
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ func _set(property: StringName, value) -> bool:
if property == LOOK_AT_TARGET_PROPERTY_NAME:
_look_at_target_path = value
var value_node_path: NodePath = value as NodePath
if not is_node_ready(): await ready

if not value_node_path.is_empty():
_should_look_at = true
if has_node(_look_at_target_path):
Expand Down Expand Up @@ -482,8 +484,8 @@ func _enter_tree() -> void:


func _exit_tree() -> void:
if Properties.pcam_host_owner:
Properties.pcam_host_owner.pcam_removed_from_scene(self)
if _has_valid_pcam_owner():
get_pcam_host_owner().pcam_removed_from_scene(self)

Properties.pcam_exit_tree(self)

Expand Down Expand Up @@ -718,6 +720,12 @@ func _get_raw_unprojected_position() -> Vector2:
func _on_dead_zone_changed() -> void:
set_global_position( _get_position_offset_distance() )


func _has_valid_pcam_owner() -> bool:
if not is_instance_valid(get_pcam_host_owner()): return false
if not is_instance_valid(get_pcam_host_owner().camera_3D): return false
return true

#endregion

# TBD
Expand Down Expand Up @@ -1075,6 +1083,7 @@ func set_camera_cull_mask(value: int) -> void:
set_camera_3D_resource(null) # Clears resource from PCam instance
else:
_camera_3D_resouce_default.cull_mask = value
if is_active(): get_pcam_host_owner().camera_3D.cull_mask = value
## Gets the Camera3D fov value assigned this PhantomCamera. The duration value is in seconds.
func get_camera_cull_mask() -> int:
if get_camera_3D_resource():
Expand All @@ -1093,6 +1102,7 @@ func set_camera_h_offset(value: float) -> void:
set_camera_3D_resource(null) # Clears resource from PCam instance
else:
_camera_3D_resouce_default.h_offset = value
if is_active(): get_pcam_host_owner().camera_3D.h_offset = value
## Gets the Camera3D fov value assigned this PhantomCamera. The duration value is in seconds.
func get_camera_h_offset() -> float:
if get_camera_3D_resource():
Expand All @@ -1111,6 +1121,7 @@ func set_camera_v_offset(value: float) -> void:
set_camera_3D_resource(null) # Clears resource from PCam instance
else:
_camera_3D_resouce_default.v_offset = value
if is_active(): get_pcam_host_owner().camera_3D.v_offset = value
## Gets the Camera3D fov value assigned this PhantomCamera. The duration value is in seconds.
func get_camera_v_offset() -> float:
if get_camera_3D_resource():
Expand All @@ -1129,6 +1140,7 @@ func set_camera_fov(value: float) -> void:
set_camera_3D_resource(null) # Clears resource from PCam instance
else:
_camera_3D_resouce_default.fov = value
if is_active(): get_pcam_host_owner().camera_3D.fov = value
## Gets the Camera3D fov value assigned this PhantomCamera. The duration value is in seconds.
func get_camera_fov() -> float:
if get_camera_3D_resource():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,17 +218,17 @@ func _pcam_tween(delta: float) -> void:
)
)

if _prev_camera_fov != _active_pcam.get_camera_fov() and _active_pcam.get_camera_3D_resource():
if _prev_camera_fov != _active_pcam.get_camera_fov():
camera_3D.set_fov(
_tween_interpolate_value(_prev_camera_fov, _active_pcam.get_camera_fov())
)

if _prev_camera_h_offset != _active_pcam.get_camera_h_offset() and _active_pcam.get_camera_3D_resource():
if _prev_camera_h_offset != _active_pcam.get_camera_h_offset():
camera_3D.set_h_offset(
_tween_interpolate_value(_prev_camera_h_offset, _active_pcam.get_camera_h_offset())
)

if _prev_camera_v_offset != _active_pcam.get_camera_v_offset() and _active_pcam.get_camera_3D_resource():
if _prev_camera_v_offset != _active_pcam.get_camera_v_offset():
camera_3D.set_v_offset(
_tween_interpolate_value(_prev_camera_v_offset, _active_pcam.get_camera_v_offset())
)
Expand Down

0 comments on commit cd4f2f1

Please sign in to comment.