3D FPS Game with AI Enemies: Mastering Pathfinding and Combat Behaviors in Three.js
This prompt was originally published by prompts.chat. It asks you to build a first-person shooter game using Three.js and JavaScript, including weapon animations, hit detection, particle effects, and AI enemies. You can use tools like ChatGPT, Claude, Gemini, Cursor, Lovable, Bolt, or v0 to generate the code. The goal is to build a playable version that you can test locally and deploy for free. With this tutorial, we’ll walk you through how to get started, run the game, test features, and deploy it using modern tools.
We assume you have basic familiarity with HTML, CSS, and JavaScript. You don’t need prior 3D experience. The AI tools can generate most of the code, but you’ll still want to tweak and debug for best results.
What you need
- A modern web browser
- An AI coding tool like ChatGPT, Claude or Gemini
- Basic understanding of HTML, CSS, and JavaScript
- A code editor (like VS Code or Cursor)
- Access to GitHub or Netlify for deployment
- Optional: Sound libraries or audio assets
The full prompt
Develop a first-person shooter game using Three.js and JavaScript. Create detailed weapon models with realistic animations and effects. Implement precise hit detection and damage systems. Design multiple game levels with various environments and objectives. Add AI enemies with pathfinding and combat behaviors. Create particle effects for muzzle flashes, impacts, and explosions. Implement multiplayer mode with team-based objectives. Include weapon pickup and inventory system. Add sound effects for weapons, footsteps, and environment. Create detailed scoring and statistics tracking. Implement replay system for kill cams and match highlights.1Choose an AI Tool and Paste the Full Prompt
Start by selecting one of your preferred AI coding tools. Popular choices include ChatGPT, Claude, Gemini, Cursor, Lovable, Bolt, or v0. Open a new chat or project window in that tool.
Paste the full prompt exactly as it appears on this page:
Develop a first-person shooter game using Three.js and JavaScript. Create detailed weapon models with realistic animations and effects. Implement precise hit detection and damage systems. Design multiple game levels with various environments and objectives. Add AI enemies with pathfinding and combat behaviors. Create particle effects for muzzle flashes, impacts, and explosions. Implement multiplayer mode with team-based objectives. Include weapon pickup and inventory system. Add sound effects for weapons, footsteps, and environment. Create detailed scoring and statistics tracking. Implement replay system for kill cams and match highlights.
Wait for the AI to generate the code. Be ready to ask follow-up questions if the output doesn’t match what’s in the prompt above.

Pro tip: Use a tool that supports multi-file generation for better code organization.
2Review and Save the Generated Code Locally
Once the AI finishes generating, carefully review the output. It should include:
- A main
index.htmlfile with Three.js integration - JavaScript files handling game logic and controls
- Assets like models or textures if included
Save all files into a folder named fps-game. Open the index.html in your browser to see the initial game.
If the AI generated multiple files, make sure they are properly linked. If you're using a tool like Cursor or v0 that supports code editing directly, you can modify and save right in the interface.
Check for errors in the console of your browser. Common issues include missing assets or incorrect paths to model files.
Pro tip: Use the browser's developer tools to inspect elements and debug runtime issues.
3Test Core Game Features
Run the game in your browser and test core mechanics:
- Movement: Use WASD keys or arrow keys to move around.
- Look Around: Move mouse to look around.
- Shooting: Click to fire weapons.
- Hit Detection: Ensure enemies react when hit.
- Particle Effects: Muzzle flashes and impacts should appear on hit.
If something isn’t working, such as shooting or enemy movement, go back to your AI tool and ask for fixes. For example:
Fix the shooting mechanics so bullets can hit enemies properly.
The AI will generate updated code that you can paste into your project.

Pro tip: Test with a single enemy first to isolate bugs in hit detection or AI behavior.
4Implement Physics and Controls
The core of any FPS game is responsive movement and physics. The AI might generate code that uses Three.js controls, like PointerLockControls for mouse look.
Ensure:
- Mouse sensitivity is adjustable
- Jumping or crouching mechanics are included if needed
- Weapon recoil or sway effects are added
- Collision detection works with environment objects
If the movement feels jittery or unresponsive, try adjusting the camera controls in your JavaScript. You can also add gravity to simulate realistic falling.
Use the AI to generate additional code blocks for:
Add a simple jump mechanic using physics.
Keep testing after each change.
Pro tip: Tune movement speed and sensitivity with trial and error for better player experience.
5Add Sound Effects and Visual Feedback
Sound is crucial to immersion. The AI might have included placeholders for audio, but you’ll want to add real sound effects.
Use libraries like Howler.js or Web Audio API to manage:
- Weapon firing sounds
- Footsteps
- Enemy growls or alerts
- Explosions and impacts
Also, enhance visual feedback:
- Add muzzle flash particles
- Create hit markers on screen
- Show damage numbers when enemies are hit
If the AI output lacks these features, prompt it with:
Add particle effects for muzzle flashes and impact explosions.
Test each sound and visual effect separately before combining them.
Pro tip: Use free audio libraries like Zapsplat or Freesound to add realistic sound assets.
6Fix Bugs and Add More Features
If you find issues with hit detection, AI enemy behavior, or animations, use follow-up prompts to refine the code.
Example fixes:
Fix the issue where enemies don’t move toward player.
You can also expand features like:
- Multiple levels with different environments
- Inventory system for weapons and health packs
- Score tracking and game stats
- Multiplayer mode using WebSockets or a backend
Each time you add a new feature, test thoroughly. AI outputs sometimes miss small but important details that break gameplay.
Make sure to save your project files often to avoid losing progress.
Pro tip: Break complex features into smaller tasks and test each part before combining them.
7Deploy Your Game for Free
Once the game is working, deploy it for others to play. GitHub Pages is a free option that works great for simple web apps.
Steps:
- Push your folder to a new GitHub repository
- Enable GitHub Pages in repo settings
- Visit the generated URL to see your live game
Alternatively, use Netlify or Vercel:
- Drag and drop your folder
- Or connect your GitHub repo
Make sure all file paths are correct in index.html. If assets like images or models don’t load, check that they’re included in the project root or correctly referenced.
The live preview of your game will be ready in minutes.
Pro tip: Use relative paths for assets and avoid hardcoded URLs to prevent deployment errors.
8Optimize Performance and Test on Devices
After deploying, test performance on different devices. A 3D FPS game can be heavy on mobile or older computers.
Optimization tips:
- Reduce polygon count in weapon models
- Use texture compression
- Limit particle effects to avoid frame drops
- Add a settings menu to adjust quality
If you notice lag, use browser dev tools to profile performance. The AI might have generated inefficient code that needs refactoring.
You can ask the AI to optimize:
Optimize rendering for mobile devices.
Test on at least one mobile browser and desktop for full compatibility.
Pro tip: Use requestAnimationFrame wisely and avoid heavy loops that block UI updates.
Adapt it to your own brand
- Modify weapon types, enemy behaviors, or levels to suit your theme
- Change the game's visual style with different shaders or color palettes
- Add a team-based objective system for multiplayer gameplay
- Integrate social features like leaderboards or replay sharing
- Include custom sound packs or voice lines for characters
- Add difficulty scaling based on player performance
- Support touch controls for mobile devices if needed
Common mistakes and fixes
- Forgetting to include all necessary assets in the project folder
- Not adjusting camera controls for proper mouse look sensitivity
- Using absolute paths that break when deployed
- Overloading the game with too many effects at once
- Ignoring browser console errors during testing
- Skipping follow-up prompts when AI output is incomplete or buggy
Frequently asked questions
Which AI tools work best for this prompt?
Tools like ChatGPT, Claude, Gemini, Cursor, Lovable, Bolt, and v0 all support generating large codebases. Pick the one you're most comfortable with.
Can I add multiplayer to my game later?
Yes, with WebSockets or a backend service like Firebase or Socket.IO, you can expand this to include online play and team objectives.
Do I need prior 3D experience?
No. The AI handles most of the Three.js complexity, but understanding basic JavaScript helps with customization.
How do I make sure my game works on mobile?
Test on devices, optimize rendering, and add touch controls. Consider using a responsive layout or scaling techniques.
Final thoughts
This tutorial shows how to build a full 3D FPS game from scratch using AI tools. You’ve learned how to generate code, test gameplay, fix issues, and deploy your project for free. The prompt above is the foundation for building something complex yet manageable with modern AI assistance. Now it's time for you to copy the prompt and try building your own version.