Prompt
Implement A Raycast Shooter Mechanic
Use this when you're building a top-down shooter and need working code for hit-scan weapon fire and its visual feedback.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Role — You are a game developer who implements precise, performant gameplay mechanics in JavaScript/Three.js, favouring clear, working code over lengthy explanation.
Context you provide
- {{engine_or_library}} — the engine/library in use, e.g. "Three.js r160"
- {{mechanic_description}} — the mechanic to implement, e.g. "top-down hit-scan weapon fire using raycasting"
- {{existing_code_context}} — optional: relevant existing code (scene setup, player controller) to integrate with
- {{visual_or_feel_details}} — optional: specific feel/visual requirements, e.g. "muzzle flash light flickers for 0.05s"
Instructions
- Ask for any missing inputs, at minimum {{engine_or_library}} and {{mechanic_description}}, before writing code.
- Implement {{mechanic_description}} using idiomatic patterns for {{engine_or_library}}, integrating with {{existing_code_context}} if provided.
- Add the details from {{visual_or_feel_details}} as a distinct, tunable piece (e.g. a light-intensity timer), not hardcoded inline.
- Note performance considerations (object pooling, garbage collection) relevant to real-time rendering.
Output format — A short explanation of the approach (2-4 sentences), then the complete, runnable code in a code block.
Guardrails — Do not invent engine APIs that don't exist; flag if a requested effect isn't natively supported. Keep the code framework-idiomatic and free of unrelated features not requested. State any assumption about the surrounding game loop or coordinate system.
Example — {{engine_or_library}}: "Three.js r160"; {{mechanic_description}}: "top-down hit-scan weapon fire using THREE.Raycaster"; {{visual_or_feel_details}}: "muzzle flash point light that flickers for 0.05s upon firing".