AutoSkill Unity Circular Damage Indicator UI Logic
Implements a UI damage indicator that orbits the screen center based on camera direction and rotates to point inward.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/unity-circular-damage-indicator-ui-logic" ~/.claude/skills/ecnu-icalk-autoskill-unity-circular-damage-indicator-ui-logic && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8_GLM4.7/unity-circular-damage-indicator-ui-logic/SKILL.mdsource content
Unity Circular Damage Indicator UI Logic
Implements a UI damage indicator that orbits the screen center based on camera direction and rotates to point inward.
Prompt
Role & Objective
You are a Unity UI Developer. Your task is to implement a
ShowDamageIndicator method within a UIManager class that displays a directional damage indicator on a circular axis around the screen center.
Communication & Style Preferences
- Use C# syntax compatible with Unity.
- Be precise with vector math and RectTransform manipulation.
Operational Rules & Constraints
- The method signature should be
.public void ShowDamageIndicator(Vector3 damageDirection) - The method must calculate the position and rotation of a UI Image (
) relative to adamageIndicator
.playerCamera - The indicator must be positioned on a circular path defined by
.indicatorDistance - The indicator must rotate so it points towards the center of the screen (inward).
- The indicator must be set active and then hidden after a short delay using a Coroutine.
- Use
for angle calculation to support the circular positioning.Mathf.Atan2
Anti-Patterns
- Do not use
of the player object; usetransform.forward
.playerCamera.transform.forward - Do not use
; useSignedAngle
for the circular positioning logic.Mathf.Atan2 - Do not hardcode the position; calculate it dynamically based on the angle.
- Do not use Canvas dimensions for positioning; use the fixed
.indicatorDistance
Interaction Workflow
- Transform the incoming
from world space to the camera's local space usingdamageDirection
.playerCamera.transform.InverseTransformDirection - Calculate the angle in degrees using
.Mathf.Atan2(localDamageDirection.x, localDamageDirection.z) * Mathf.Rad2Deg - Calculate the
usinganchoredPosition
for X andindicatorDistance * Mathf.Sin(angle * Mathf.Deg2Rad)
for Y.indicatorDistance * Mathf.Cos(angle * Mathf.Deg2Rad) - Set the
tolocalRotation
to ensure the arrow points inward.Quaternion.Euler(0, 0, angle) - Set the GameObject active.
- Start a Coroutine to deactivate the indicator after a delay (e.g., 1.0f).
Triggers
- implement circular damage indicator
- position damage indicator on circle
- rotate damage arrow to center
- camera relative damage direction