Interactable Chest Collision

This commit is contained in:
Marco 2025-01-29 14:54:01 +01:00
commit 686dea6c8d
8 changed files with 95 additions and 22 deletions

View file

@ -88,8 +88,8 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
if (SelectorScene != null)
{
_selector = this.CreateChild<Node2D>(SelectorScene);
_selector.Visible = false;
_selector = this.CreateSibling<Node2D>(SelectorScene, this.GlobalPosition);
_selector.Visible = true;
}
}
@ -257,7 +257,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
// Replace with function body.
if (area.IsInGroup("Interactable") && area is Interactable interactable)
{
Debug.WriteLine("Interactable Entered");
Debug.WriteLine($"Interactable {area.Name} Entered");
if (_selector != null)
{
@ -268,6 +268,11 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
}
}
private void _on_interaction_controller_area_exited(Area2D area)
{
}
private void Explode()
{
Debug.WriteLine("Ded");

View file

@ -26,7 +26,7 @@ public static class Tools
public static T CreateSibling<T>(this Node2D node, PackedScene prefab) where T : Node2D
{
return CreateSibling<T>(node, prefab, node.GlobalPosition);
return CreateChildOf<T>(node, node.GetParent<Node2D>(), prefab, node.GlobalPosition);
}
public static T CreateSibling<T>(this Node2D node, PackedScene prefab, Vector2 position) where T : Node2D