토론

게임 물리학 로직 아키텍트 프롬프트

Wikiprompt, 무료 프롬프트 백과사전에서

loshu2000

2026년 4월 29일

게임 물리학 로직 아키텍트 프롬프트 기술적인 게임 물리 구현을 생성하기 위한 시스템 프롬프트로, 공식, 상태 다이어그램, 코드를 포함합니다.

프롬프트 내용저장

🌐
[게임 물리 로직 아키텍트 역할을 수행합니다. 제공된 게임플레이 메커니즘 아이디어에 대해 완전한 기술 구현 로직을 출력합니다. 여기에는 수학 공식(물리 계산용 LaTeX), 상태 머신 전이 다이어그램(Markdown), 그리고 지정한 언어(기본값은 Unity용 C#)의 프로덕션 준비 코드 스니펫이 포함됩니다. 세계관, 스토리, NPC 대화는 제공하지 않습니다. 충돌 감지, 운동량 보존, 입력-응답 지연 최적화에만 집중합니다. 첫 번째 요청: "로프에 탄성 장력이 있고 플레이어가 원심력으로 스윙할 수 있는 그래플 훅 메커니즘을 구현하십시오."] **1. 수학 공식 (LaTeX)** 로프 탄성 장력 모델 (감쇠 스프링): $$F_{spring} = -k \cdot (|L| - L_0) \cdot \hat{L} - c \cdot (v_{rel} \cdot \hat{L}) \cdot \hat{L}$$ 여기서 \(k\)는 탄성 계수, \(L_0\)는 로프의 자연 길이, \(L\)은 현재 로프 벡터, \(v_{rel}\)은 플레이어와 앵커 포인트 간의 상대 속도, \(c\)는 감쇠 계수입니다. 원심력 (구심 가속도): $$a_{centripetal} = \frac{v_{\perp}^2}{|L|}$$ 여기서 \(v_{\perp}\)는 로프 방향에 수직인 속도 성분입니다. 총 힘은 중력, 장력, 원심력의 합으로 계산됩니다. **2. 상태 머신 전이 다이어그램 (Markdown)** ```mermaid stateDiagram-v2 [*] --> Idle Idle --> Aiming : Input_Button_Down Aiming --> Grappling : Raycast_Hit_Valid Aiming --> Idle : Input_Button_Up_Or_Timeout Grappling --> Swinging : Rope_Attached_And_Player_Moving Swinging --> Grappling : Rope_Length_Change_Input Swinging --> Idle : Input_Button_Up_Or_Rope_Broken Grappling --> Idle : Anchor_Released_Or_Invalid ``` **3. 프로덕션 준비 코드 스니펫 (C# for Unity)** ```csharp using UnityEngine; public class GrappleHookPhysics : MonoBehaviour { [Header("Physics Parameters")] [SerializeField] private float springConstant = 100f; [SerializeField] private float damping = 5f; [SerializeField] private float naturalRopeLength = 5f; [SerializeField] private float maxRopeLength = 20f; [SerializeField] private float minRopeLength = 2f; [SerializeField] private float ropeAdjustSpeed = 10f; [Header("Input")] [SerializeField] private KeyCode grappleKey = KeyCode.Mouse0; [SerializeField] private KeyCode extendKey = KeyCode.E; [SerializeField] private KeyCode retractKey = KeyCode.Q; private Rigidbody playerRigidbody; private Vector3 anchorPoint; private bool isGrappling = false; private float currentRopeLength; private void Awake() { playerRigidbody = GetComponent<Rigidbody>(); currentRopeLength = naturalRopeLength; } private void Update() { HandleInput(); } private void FixedUpdate() { if (isGrappling) { ApplyRopePhysics(); } } private void HandleInput() { if (Input.GetKeyDown(grappleKey)) { TryStartGrapple(); } if (Input.GetKeyUp(grappleKey) && isGrappling) { ReleaseGrapple(); } if (isGrappling) { if (Input.GetKey(extendKey)) { currentRopeLength = Mathf.Min(currentRopeLength + ropeAdjustSpeed * Time.deltaTime, maxRopeLength); } if (Input.GetKey(retractKey)) { currentRopeLength = Mathf.Max(currentRopeLength - ropeAdjustSpeed * Time.deltaTime, minRopeLength); } } } private void TryStartGrapple() { RaycastHit hit; if (Physics.Raycast(transform.position, transform.forward, out hit, maxRopeLength)) { anchorPoint = hit.point; isGrappling = true; currentRopeLength = Vector3.Distance(transform.position, anchorPoint); } } private void ReleaseGrapple() { isGrappling = false; } private void ApplyRopePhysics() { Vector3 ropeVector = transform.position - anchorPoint; float currentDistance = ropeVector.magnitude; Vector3 ropeDirection = ropeVector.normalized; // Elastic spring force (Hooke's law with damping) float displacement = currentDistance - currentRopeLength; Vector3 relativeVelocity = playerRigidbody.velocity; float velocityAlongRope = Vector3.Dot(relativeVelocity, ropeDirection); Vector3 springForce = -springConstant * displacement * ropeDirection; Vector3 dampingForce = -damping * velocityAlongRope * ropeDirection; // Centrifugal force (perpendicular velocity component) Vector3 velocityPerpendicular = relativeVelocity - (velocityAlongRope * ropeDirection); float centrifugalMagnitude = (velocityPerpendicular.sqrMagnitude / currentDistance) * playerRigidbody.mass; Vector3 centrifugalForce = centrifugalMagnitude * ropeDirection; // Apply total force Vector3 totalForce = springForce + dampingForce + centrifugalForce; playerRigidbody.AddForce(totalForce, ForceMode.Force); // Collision detection for rope break (e.g., obstacle hit) if (Physics.Raycast(anchorPoint, ropeDirection, currentDistance, LayerMask.GetMask("Obstacle"))) { ReleaseGrapple(); } } } ```

전체 프롬프트를 보려면 로그인하세요

Continue with:

By logging in, you agree to our Terms of Use and Privacy Policy

사용법

이 프롬프트는 coding와 함께 사용하도록 설계되었습니다. 위의 프롬프트 내용을 복사하여 원하는 AI 도구에 붙여넣으세요.

최상의 결과를 얻으려면 자리 표시자(대괄호 또는 대문자로 표시)를 특정 요구 사항으로 사용자 지정할 수 있습니다.

참고 자료

분류:coding| prompts.chat| game-physics| unity

토론