Gen AI

Unlocking Worlds with GenAI Assistant

Horizon Creator Academy

Hands-On Challenge: Scripting with the Gen AI Assistant

Hands-On Challenge Overview

This challenge focuses on using the Gen AI Assistant to accelerate your scripting workflow. You will learn how to turn natural language prompts into working TypeScript code and refine it through iteration.
You’ll learn how to:
  • Access the Gen AI Assistant in the Desktop Editor.
  • Write effective prompts to generate functional scripts.
  • Use "Code and Act" mode to automatically apply scripts.
  • Iterate on your code to refine object behaviors.
Estimated Time: 1 hour

What You'll Need:

  • Windows PC
  • Access to the Worlds Desktop Editor
  • Visual Studio Code

Challenge Steps:

1. Access the Assistant
  • Open the Horizon Worlds Desktop Editor and enter a world in Edit mode.
  • Locate the Gen AI menu in the top toolbar.
  • Select Assistant to open the chat panel.
  • Take a moment to review the interface, including the prompt box and mode selection.
2. Generate Your First Script
  • In the chat panel, ensure you are on the Assistant tab with Code and Act mode selected.
  • Type a clear, specific prompt. For this challenge, try: "Make a platform that moves up and down continuously."
  • Review the generated TypeScript code. The Assistant should provide a platform asset and a script that implements the movement logic.
3. Iterate and Refine
  • In the same chat session, type a follow-up prompt: "Make it move faster and pause for 2 seconds at the top."
  • Observe how the Assistant updates the code to include the new requirements.
4. Try More Complex Logic
  • Type a prompt like: "Create a timer that can be started, stopped, and restarted when player enters labeled triggers"
  • Enter Preview mode to test the interaction.
5. Make manual modifications
  • Try editing the generated code to print console messages when the player enters the trigger.
  • Open the console tab in the Editor.
  • Enter Preview mode to test the interaction. You should see the console messages in the console tab.

Level Up:

  • Open the Gen AI Chat History at the top of the Gen AI Panel to revisit a previous prompt and regenerate a variation of it.
  • Try creating a player manager script, such as "Create a player manager that keeps track of who is currently in the world"
  • Experiment with the Code only mode for generating code snippets that you can implement manually.

Need Help?

Related Links