Skip to content

MuharremTozan/Agentic-Duel / .agent/skills/unity-interaction

unity-interaction

Verified

Generic raycast-based interaction system. Works for any game genre (RPG, Platformer, Simulation).

assets/code/InteractionController.cs.txt

View on GitHub
using UnityEngine;

namespace Standard.Interaction {
    /// <summary>
    /// Base class for interactable objects with Raycast detection.
    /// Handles selection highlighting and input routing.
    /// </summary>
    public class InteractionController : MonoBehaviour, IInteractor {
        [Header("Detection")]
        [SerializeField] private float interactDistance = 2f;
        [SerializeField] private LayerMask interactableLayer;

        private IInteractable _selectedTarget;

        private void Update() {
            DetectTarget();
            HandleInput();
        }

        private void DetectTarget() {
            Vector3 direction = transform.forward;
            
            if (Physics.Raycast(transform.position, direction, out RaycastHit hit, interactDistance, interactableLayer)) {
                if (hit.transform.TryGetComponent(out IInteractable interactable)) {
                    SetSelectedTarget(interactable);
                    return;
                }
            }
            
            SetSelectedTarget(null);
        }

        private void HandleInput() {
            if (_selectedTarget == null) return;

            if (Input.GetKeyDown(KeyCode.E)) {
                _selectedTarget.Interact(this);
            }
            
            if (Input.GetKeyDown(KeyCode.F)) {
                _selectedTarget.InteractAlternate(this);
            }
        }

        private void SetSelectedTarget(IInteractable target) {
            if (_selectedTarget == target) return;
            _selectedTarget = target;
            // Fire selection event here if using event channels
        }
    }
}
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 197kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall