using UnityEngine; /// /// Example interactive object: A ledge that the player can jump over. /// Can have conditions like requiring a minimum jump height or specific equipment. /// public class Ledge : MonoBehaviour, IInteractiveObject { [Header("Ledge Settings")] public string ledgeName = "Ledge"; public float height = 2f; // Height of the ledge [SerializeField] private float requiredJumpPower = 1f; // 0-1 scale, 1 being maximum jump [Header("Traversal")] public Transform jumpStartPoint; // Where player should stand to jump public Transform jumpEndPoint; // Where player lands after jumping public bool isTraversable = true; public Vector3 GetInteractionPoint() { if (jumpStartPoint != null) return jumpStartPoint.position; return transform.position; } public bool CanInteract() { return isTraversable; } public void Interact(GameObject player) { if (!isTraversable) { Debug.Log("Cannot jump over this ledge!", gameObject); return; } Debug.Log($"Player {player.name} is jumping over {ledgeName}", gameObject); // You can trigger jump animation, apply force, teleport player, etc. // Example: Move player to the end point if (jumpEndPoint != null) { var movement = player.GetComponent(); if (movement != null) { movement.MoveTo(jumpEndPoint.position); } else { player.transform.position = jumpEndPoint.position; } } } public string GetDisplayName() => $"{ledgeName} (Height: {height}m)"; /// /// Check if the player can safely jump this ledge /// (Implement with player stats, equipment, etc.) /// public bool CanPlayerJump(Character player) { // Add custom logic here // Example: check if player has enough stamina, equipment bonuses, etc. return true; } /// /// Block the ledge (might be destroyed, blocked by debris, etc.) /// public void Block() { isTraversable = false; Debug.Log($"{ledgeName} is now blocked!", gameObject); } void OnDrawGizmos() { // Visual debugging if (jumpStartPoint != null && jumpEndPoint != null) { Gizmos.color = Color.green; Gizmos.DrawLine(jumpStartPoint.position, jumpEndPoint.position); Gizmos.DrawWireSphere(jumpStartPoint.position, 0.2f); Gizmos.DrawWireSphere(jumpEndPoint.position, 0.2f); } } }