• Studio

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • CREATE

    Scripting

    Advanced

    Edit

    Scripting a GameObject

    Introduction

    In this guide you will learn how to create a basic Lua script and add it to a game object.

    What is a Lua Script?

    ❗️ When building a Highrise World, C# scripts are not included in the build. Make sure to use Lua scripts for your game objects.

    Creating a Hello World Script

    Let's create a simple script that prints "Hello, World!" to the console when the game starts.

    Step 1: Create a Lua Script

    1. Open your project in Unity.
    2. In the Project panel, right-click and select Create > Highrise > Lua Script.
    3. Name the script HelloWorldScript and press Enter.

    Step 2: Opening the Script

    1. Double-click the HelloWorldScript to open it in your code editor.
    2. Write the following code in the script:
    -- This script prints "Hello, World!" to the console
    print("Hello, World!")
    

    Learn more about coding fundamentals.

    Step 3: Attaching the Script to a GameObject

    1. Right-click the Hierarchy panel.
    2. Select 3D Object > Create Empty to create an empty game object.
    3. Rename the object to HelloWorldObject.
    4. Pick the HelloWorldObject in the Hierarchy panel.
    5. Drag the HelloWorldScript onto the HelloWorldObject in the Inspector panel.

    Step 4: Testing the Script

    1. Hit Play in Unity to enter Play Mode.
    2. Check the console for the "Hello, World!" message.

    Conclusion

    You have successfully created a Lua script that prints "Hello, World!" to the console when the game starts. This simple script demonstrates the basics of scripting in Highrise Studio. Experiment with different scripts to add interactivity and functionality to your game objects.

    Video Preview

    Next Steps

    Delve deeper into lua scripting by learning about:

    Updated 17 days ago

    PocketWorlds Icon

    © 2024 Pocket Worlds. All rights reserved.