Semi-working Interactables rework
This commit is contained in:
@@ -157,11 +157,28 @@ public class InputManager : MonoBehaviour
|
||||
Collider2D hit = Physics2D.OverlapPoint(worldPos, mask);
|
||||
if (hit != null)
|
||||
{
|
||||
var interactable = hit.GetComponent<ITouchInputConsumer>();
|
||||
var interactable = hit.GetComponent<Interactable>();
|
||||
if (interactable != null)
|
||||
{
|
||||
Debug.unityLogger.Log("Interactable", $"[InputManager] Delegating tap to interactable at {worldPos} (GameObject: {hit.gameObject.name})");
|
||||
interactable.OnTap(worldPos);
|
||||
// Find the player Character (by tag)
|
||||
var playerObj = GameObject.FindGameObjectWithTag("Player");
|
||||
var playerCharacter = playerObj != null ? playerObj.GetComponent<Character>() : null;
|
||||
if (playerCharacter != null)
|
||||
{
|
||||
InteractionOrchestrator.Instance.RequestInteraction(interactable, playerCharacter);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("[InputManager] Player Character not found for interaction delegation.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// Fallback: support other ITouchInputConsumer implementations
|
||||
var consumer = hit.GetComponent<ITouchInputConsumer>();
|
||||
if (consumer != null)
|
||||
{
|
||||
consumer.OnTap(worldPos);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Input
|
||||
/// Handles player movement in response to tap and hold input events.
|
||||
/// Supports both direct and pathfinding movement modes, and provides event/callbacks for arrival/cancellation.
|
||||
/// </summary>
|
||||
public class PlayerTouchController : MonoBehaviour, ITouchInputConsumer
|
||||
public class PlayerTouchController : Character, ITouchInputConsumer
|
||||
{
|
||||
// --- Movement State ---
|
||||
private Vector3 targetPosition;
|
||||
|
||||
Reference in New Issue
Block a user