-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move all spring arm initializaiton code out of _process into _ready (#282) * Move all spring arm initializaiton code out of _process into _ready. Resolves #193 * Making _follow_spring_arm explicitly top_level * Default _follow_spring_arm.position initialization to the original pcam position if follow_target is not available * Updated plugin.cfg to 0.7.1 * Change Camera3DResource.cull_mask to use export_flags_3d_render. Resolves #290 (#293) * Only show viewfinder if the active PCam's mode is framed (#295) * Only show viewfinder in the correct follow mode * Adjust comments * Reorder early returns * Remove unneeded type cast * Updated Editor Updater wording for major releases * Improved Limit Target error setter * Added FUNDING.yml * 2D Follow Physics Interpolation (#294) * Initial _process / _physics_process logic split * More 2d physics interpolation supported - [Added] Interpolation Update Mode to PCamHost - [Added] Additional warnings * Commented out 4.3 specific code * Stripped out a few todo comments * Removed uneeded checkers * Added physics body checker for Group Follow * Added reset_physics_interpolation - [Updated] Physics Interpolation to use string setters * Added physics target checker to PCam3D - [Moved] Follow Targets setters/getters closer to other Follow setters/getters * Aligned PCam2D' script with PCam3D's * Added missing variable assignment * Added missing return for Framed Follow checker * Removed unneeded boolean flag * Tidied up process logic * Added Jitter Tip output * Added physics checker to Look At Group * Updated parameter type from NodePath to Node3D * Updated spacing for setters/getter functions * Set _player_visual to top level in 2D example scene * Added additional jitter context * Updated append_look_at_targets_array * Added Godot 4.3 2D example scene variants --------- Co-authored-by: ZenithStar <ZenithStar@users.noreply.github.com> Co-authored-by: audeck <55060124+audeck@users.noreply.github.com>
- Loading branch information
1 parent
d8a6e24
commit 0b2b1a9
Showing
23 changed files
with
5,051 additions
and
410 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# These are supported funding model platforms | ||
|
||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] | ||
patreon: # Replace with a single Patreon username | ||
open_collective: # Replace with a single Open Collective username | ||
ko_fi: ramokz | ||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
liberapay: # Replace with a single Liberapay username | ||
issuehunt: # Replace with a single IssueHunt username | ||
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry | ||
polar: # Replace with a single Polar username | ||
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username | ||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] |
641 changes: 641 additions & 0 deletions
641
addons/phantom_camera/examples/example_scenes/2D-4.3/2d_example_scene.tscn
Large diffs are not rendered by default.
Oops, something went wrong.
641 changes: 641 additions & 0 deletions
641
addons/phantom_camera/examples/example_scenes/2D-4.3/2d_follow_framed_example_scene.tscn
Large diffs are not rendered by default.
Oops, something went wrong.
648 changes: 648 additions & 0 deletions
648
addons/phantom_camera/examples/example_scenes/2D-4.3/2d_follow_group_example_scene.tscn
Large diffs are not rendered by default.
Oops, something went wrong.
659 changes: 659 additions & 0 deletions
659
addons/phantom_camera/examples/example_scenes/2D-4.3/2d_follow_path_example_scene.tscn
Large diffs are not rendered by default.
Oops, something went wrong.
718 changes: 718 additions & 0 deletions
718
addons/phantom_camera/examples/example_scenes/2D-4.3/2d_limit_example_scene.tscn
Large diffs are not rendered by default.
Oops, something went wrong.
793 changes: 793 additions & 0 deletions
793
addons/phantom_camera/examples/example_scenes/2D-4.3/2d_tweening_example_scene.tscn
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
addons/phantom_camera/examples/scripts/2D/2d_room_limit_tween_4.3.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
extends Node2D | ||
|
||
@onready var pcam_room_left: PhantomCamera2D = %RoomLeftPhantomCamera2D | ||
@onready var pcam_room_centre: PhantomCamera2D = %RoomCentrePhantomCamera2D | ||
@onready var pcam_room_right: PhantomCamera2D = %RoomRightPhantomCamera2D | ||
|
||
@onready var player: Node2D = %CharacterBody2D | ||
|
||
@onready var area_2d_room_left: Area2D = %RoomLeftArea2D | ||
@onready var area_2d_room_centre: Area2D = %RoomCentreArea2D | ||
@onready var area_2d_room_right: Area2D = %RoomRightArea2D | ||
|
||
|
||
func _ready(): | ||
pcam_room_left.set_follow_offset(Vector2(0, -80)) | ||
pcam_room_right.set_follow_offset(Vector2(0, -80)) | ||
|
||
area_2d_room_left.body_entered.connect(_on_body_entered.bind(pcam_room_left)) | ||
area_2d_room_centre.body_entered.connect(_on_body_entered.bind(pcam_room_centre)) | ||
area_2d_room_right.body_entered.connect(_on_body_entered.bind(pcam_room_right)) | ||
|
||
area_2d_room_left.body_exited.connect(_on_body_exited.bind(pcam_room_left)) | ||
area_2d_room_centre.body_exited.connect(_on_body_exited.bind(pcam_room_centre)) | ||
area_2d_room_right.body_exited.connect(_on_body_exited.bind(pcam_room_right)) | ||
|
||
|
||
func _on_body_entered(body: Node2D, pcam: PhantomCamera2D) -> void: | ||
if body == player: | ||
pcam.set_follow_target(player) | ||
pcam.set_priority(20) | ||
|
||
|
||
func _on_body_exited(body: Node2D, pcam: PhantomCamera2D) -> void: | ||
if body == player: | ||
pcam.set_priority(0) | ||
pcam.set_follow_target(null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
176 changes: 176 additions & 0 deletions
176
addons/phantom_camera/examples/scripts/2D/player_character_body_2d_4.3.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
extends CharacterBody2D | ||
|
||
@onready var _player_area2d = %PlayerArea2D | ||
@onready var _player_visuals: Node2D = %PlayerVisuals | ||
@onready var _player_sprite: Sprite2D = %PlayerSprite | ||
@onready var _interaction_prompt: Panel = %InteractionPrompt | ||
@onready var _ui_sign: Control | ||
@onready var _dark_overlay: ColorRect = %DarkOverlay | ||
|
||
const KEY_STRINGNAME: StringName = "Key" | ||
const ACTION_STRINGNAME: StringName = "Action" | ||
const INPUT_MOVE_LEFT_STRINGNAME: StringName = "move_left" | ||
const INPUT_MOVE_RIGHT_STRINGNAME: StringName = "move_right" | ||
|
||
const SPEED = 350.0 | ||
const JUMP_VELOCITY = -750.0 | ||
|
||
# Get the gravity from the project settings to be synced with RigidBody nodes. | ||
var gravity: int = 2400 | ||
var _is_interactive: bool | ||
var _can_open_inventory: bool | ||
var _movement_disabled: bool | ||
var tween: Tween | ||
var _interactive_UI: Control | ||
var _active_pcam: PhantomCamera2D | ||
|
||
enum InteractiveType { | ||
NONE = 0, | ||
ITEM = 1, | ||
INVENTORY = 2, | ||
} | ||
var _interactive_object: InteractiveType = InteractiveType.NONE | ||
|
||
var InputMovementDic: Dictionary = { | ||
INPUT_MOVE_LEFT_STRINGNAME: { | ||
KEY_STRINGNAME: KEY_A, | ||
ACTION_STRINGNAME: INPUT_MOVE_LEFT_STRINGNAME | ||
}, | ||
INPUT_MOVE_RIGHT_STRINGNAME: { | ||
KEY_STRINGNAME: KEY_D, | ||
ACTION_STRINGNAME: INPUT_MOVE_RIGHT_STRINGNAME | ||
}, | ||
} | ||
|
||
|
||
func _ready() -> void: | ||
_player_area2d.connect("body_shape_entered", _show_prompt) | ||
_player_area2d.connect("body_shape_exited", _hide_prompt) | ||
|
||
_ui_sign = owner.get_node("%UISign") | ||
|
||
for input in InputMovementDic: | ||
var key_val = InputMovementDic[input].get(KEY_STRINGNAME) | ||
var action_val = InputMovementDic[input].get(ACTION_STRINGNAME) | ||
|
||
var movement_input = InputEventKey.new() | ||
movement_input.physical_keycode = key_val | ||
InputMap.add_action(action_val) | ||
InputMap.action_add_event(action_val, movement_input) | ||
|
||
if Engine.get_version_info().major == 4 and \ | ||
Engine.get_version_info().minor < 3: | ||
printerr("This scene is designed to only work properly in Godot 4.3 or later that supports 2D Physics Interpolation.") | ||
printerr("Please run the other 2D example scenes in the other directory.") | ||
|
||
|
||
func _unhandled_input(event: InputEvent) -> void: | ||
if _is_interactive: | ||
if Input.is_physical_key_pressed(KEY_F): | ||
if tween: | ||
tween.kill() | ||
|
||
if not _movement_disabled: | ||
tween = get_tree().create_tween() | ||
|
||
_movement_disabled = true | ||
_active_pcam.set_priority(10) | ||
|
||
_show_interactive_node(_interactive_UI) | ||
_interactive_node_logic() | ||
|
||
else: | ||
_hide_interactive_node(_interactive_UI) | ||
_interactive_node_logic() | ||
|
||
|
||
if Input.is_physical_key_pressed(KEY_ESCAPE) and _movement_disabled: | ||
_hide_interactive_node(_interactive_UI) | ||
_interactive_node_logic() | ||
|
||
|
||
func _show_interactive_node(UI: Control) -> void: | ||
UI.modulate.a = 0 | ||
UI.visible = true | ||
tween.tween_property(UI, "modulate", Color.WHITE, 1).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_CIRC) | ||
|
||
|
||
func _hide_interactive_node(UI: Control) -> void: | ||
_movement_disabled = false | ||
_active_pcam.set_priority(0) | ||
UI.visible = false | ||
|
||
|
||
func _interactive_node_logic() -> void: | ||
match _interactive_object: | ||
2: | ||
if _movement_disabled: | ||
_dark_overlay.set_visible(true) | ||
else: | ||
_dark_overlay.set_visible(false) | ||
|
||
|
||
func _physics_process(delta: float) -> void: | ||
if not is_on_floor(): | ||
velocity.y += gravity * delta | ||
|
||
if Input.is_action_just_pressed("ui_accept") and is_on_floor(): | ||
velocity.y = JUMP_VELOCITY | ||
|
||
if _movement_disabled: return | ||
|
||
var input_dir: = Input.get_axis( | ||
INPUT_MOVE_LEFT_STRINGNAME, | ||
INPUT_MOVE_RIGHT_STRINGNAME | ||
) | ||
|
||
if input_dir: | ||
velocity.x = input_dir * SPEED | ||
if input_dir > 0: | ||
_player_sprite.set_flip_h(false) | ||
elif input_dir < 0: | ||
_player_sprite.set_flip_h(true) | ||
else: | ||
velocity.x = move_toward(velocity.x, 0, SPEED) | ||
|
||
move_and_slide() | ||
|
||
|
||
func _show_prompt(body_rid: RID, body: Node2D, body_shape_index: int, local_shape: int) -> void: | ||
if body is TileMap: | ||
var tile_map: TileMap = body | ||
|
||
var tile_coords: Vector2i = tile_map.get_coords_for_body_rid(body_rid) | ||
var cell_data: TileData = tile_map.get_cell_tile_data(1, tile_coords) | ||
|
||
if cell_data: | ||
var cell_data_type: StringName = cell_data.get_custom_data("Type") | ||
# var cell_global_pos: Vector2 = tile_map.to_global(tile_map.map_to_local(tile_coords)) | ||
_is_interactive = true | ||
_interaction_prompt.set_visible(true) | ||
|
||
match cell_data_type: | ||
"Sign": | ||
_interactive_UI = owner.get_node("%UISign") | ||
_active_pcam = %ItemFocusPhantomCamera2D | ||
_interactive_object = InteractiveType.ITEM | ||
"Inventory": | ||
_interactive_UI = owner.get_node("%UIInventory") | ||
_interactive_object = InteractiveType.INVENTORY | ||
_active_pcam = %InventoryPhantomCamera2D | ||
|
||
|
||
func _hide_prompt(body_rid: RID, body: Node2D, body_shape_index: int, local_shape: int) -> void: | ||
if body is TileMap: | ||
var tile_map: TileMap = body | ||
|
||
var tile_coords: Vector2i = tile_map.get_coords_for_body_rid(body_rid) | ||
var cell_data: TileData = tile_map.get_cell_tile_data(1, tile_coords) | ||
|
||
if cell_data: | ||
_interaction_prompt.set_visible(false) | ||
_is_interactive = false | ||
_interactive_UI = null | ||
_interactive_object = InteractiveType.NONE | ||
_active_pcam = null | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.