Thursday, August 17, 2023
HomeiOS DevelopmentConcentrating on the Steam Deck with Godot

Concentrating on the Steam Deck with Godot


Embark on an exhilarating gaming journey with the proper pairing: Godot, the versatile and user-friendly open-source sport engine, and the Steam Deck, an thrilling handheld gaming system by Valve. This dynamic duo opens up a world of potentialities, empowering sport builders and lovers alike to unleash their creativity and expertise gaming on the transfer like by no means earlier than!

Notice: When you’re new to Godot, I like to recommend testing my Getting Began information for a fast introduction.

On this tutorial, I’ll information you thru the method of making ready a Godot challenge particularly for the Steam Deck, sharing beneficial suggestions alongside the way in which. The Steam Deck, developed by Valve, is a handheld gaming system that primarily features as a conveyable PC, enabling you to take pleasure in your Steam library whereas on the transfer. With handheld gaming gadgets gaining immense reputation, growing for the Steam Deck can open doorways to thrilling alternatives. Godot, an open-source sport engine, is gaining recognition for its user-friendly interface and highly effective options. This makes it an excellent alternative for creating each 2D and 3D video games.

Getting Began

You’ll be able to obtain the supplies for this tutorials through the Obtain Supplies hyperlink on the high and backside of this web page.
To comply with alongside, you’ll want the next:

  • Godot put in in your laptop
  • A Steam Deck to push the construct to
  • (non-obligatory) A gamepad to arrange and check the enter in Godot

After finishing this tutorial, you’ll be conversant in:

  • Understanding the Steam Deck {hardware}
  • Establishing your Godot challenge for the Steam Deck
  • Detecting the Steam Deck
  • Dealing with enter
  • Sport efficiency issues and testing

Understanding the Steam Deck {Hardware}

Earlier than delving into Godot, it’s a good suggestion to take a better take a look at what makes the Steam Deck tick.

Specs

Right here’s an summary of the Steam Deck’s specs:

  • CPU: Customized Zen 2 AMD APU
  • GPU: AMD RDNA 2 “Van Gogh”
  • RAM: 16 GB LPDDR5 on-board RAM
  • Display: 7-inch touchscreen with a 16:10 side ratio, 1280×800 decision
  • Enter Controls: Xbox controller buttons, bumpers, triggers and D-pad + trackpads and touchscreen
  • Connectivity: USB-C, Bluetooth, Wi-Fi
  • Battery: 40 watt-hour (2-8 hours of gameplay)
  • Storage: 64 GB eMMC or 256-512 GB NVMe SSD
  • Working System: SteamOS (KDE Linux)
  • Value: $399-$649

Issues for Sport Growth

You may be questioning what all of this implies within the context of sport improvement.

For a small system at an inexpensive worth, the Steam Deck packs a punch. The Steam Deck is much more highly effective than the Nintendo Change, however not on par with trendy desktops. If you wish to examine it to a gaming PC, it provides about the identical efficiency as a GTX 1050 or an AMD Radeon RX 560. This implies you’ll want to contemplate its limitations when growing for it. Easy video games will work fantastic, however extra advanced video games will must be optimized with the intention to run easily.

The small display and low decision make it tough to learn fantastic textures and character animations. You need to enlarge UI components like textual content to make them simpler to learn. It is a good apply anyway by way of accessibility.

An excellent upside is the Steam Deck’s controller format. In case your sport helps Xbox controller enter, will probably be appropriate with the Steam Deck with none extra work. Gamers may customise the format to their liking utilizing the Steam Deck’s controller settings, which might map keyboard, gamepad and mouse enter to the system’s controls. Some folks have even made MMORPGs work with the Steam Deck this fashion, that are identified for his or her ample keyboard shortcuts.

As a result of the Steam Deck has a battery, you’ll need enable for shorter play classes and optimize your sport for battery life. Ideally, the participant can tweak the settings between battery life and efficiency.

I received’t be masking how you can deal with all of those issues on this tutorial, however be certain to maintain them in thoughts. It’s a good suggestion to check how effectively your sport runs on the Steam Deck earlier than optimizing it. You may be stunned by how effectively it runs with none changes.

Up subsequent is having a look on the pattern challenge.

Exploring the Challenge

This challenge is a small 3D automobile driving sandbox impressed by Micro Machines. There’s a monitor and some mountains to drive on.

Operating the Challenge

Begin by opening the starter challenge in Godot. You need to see a 3D scene with a automobile.

3D car

Press F5 to run the challenge and drive the automobile round. Listed below are the controls:

  • A or Left: Steer left
  • D or Proper: Steer proper
  • W, Up or Area: Speed up
  • S or Down: Brake
  • Ctrl/Cmd: Change the digicam view

Driving car around

After testing the challenge, check out the Scene dock of the stage scene.

Level nodes

Right here’s a fast rundown:

  • CameraManager: A daily node with a script connected to change the lively digicam
  • WorldEnvironment: The lightning settings for the extent
  • DirectionalLight3D: A directional mild that acts as a digital solar
  • BirdsEyeCamera: A digicam that follows the automobile from above
  • LevelModel: The 3D mannequin and colliders that represents the extent
  • Automobile: The automobile scene
  • CanvasLayer: The canvas on which you’ll add Management nodes to make a person interface. There’s already a label right here with a clear background.

You’ll construct upon these nodes all through the tutorial.

Challenge Settings

Out of the field, new Godot initiatives are able to be run on the Steam Deck. Nevertheless, there’s one setting I like to recommend altering throughout improvement: the viewport measurement. The default worth is about to 1152×648, which doesn’t match the 1280×800 decision of the Steam Deck. By setting the viewport measurement to match, it’s simpler to preview what the sport will appear like on the precise system.

To alter the viewport measurement, open the Challenge Settings by deciding on Challenge ▸ Challenge Settings.

Project Settings

Now choose Window on the left.

Window

Subsequent, set the Viewport Width to 1280 and Viewport Peak to 800.

Viewport width 1280 height 800

Lastly, click on the Shut button to shut the window. Open the 2D display utilizing the tabs on the high, and also you’ll see a blue define within the heart display if you happen to zoom out. These are the bounds of the display you’ll be working in.

Blue outline in viewport

With that out of the way in which, it’s time to get to the enjoyable elements!

Detecting the Steam Deck

Godot doesn’t have a built-in variable to find out if a tool is a Steam Deck. What it does have is a set of features that may learn each the software program and {hardware} data from the system. From this data, you possibly can detect if the system is a Steam Deck if you understand what to search for. To do this, you possibly can add a script to the data label on the high left which can show the data and detect in case your challenge is working on a Steam Deck.

First, choose CanvasLayer ▸ Data ▸ MarginContainer ▸ SystemInfoLabel within the Scene dock.

SystemInfoLabel

Now connect a brand new script to the label, identify it system_info_label.gd and place it within the scripts folder.

Label path

This could mechanically open the Script display and show the brand new script. To learn the system data and add it to the label, change the _ready operate with the next:

func _ready() -> void:
    self.textual content = "" # 1

    self.textual content += "OS: " + OS.get_name() + "n" # 2
    self.textual content += "Distro: " + OS.get_distribution_name() + "n" # 3
    self.textual content += "CPU: " + OS.get_processor_name() + "n" # 4
    self.textual content += "GPU: " + RenderingServer.get_rendering_device().get_device_name() + "n" # 5

Right here’s a abstract of what this does:

  1. Clear the textual content of the label
  2. Use OS.get_name() to return the identify of the working system the construct targets. Confusingly, this received’t at all times match the identify of the particular OS. The n provides a brand new line on the finish.
  3. OS.get_distribution_name() returns the identify of the distribution. On Home windows (and Proton), that is “Home windows”. On Linux, that is the identify of the distribution, similar to “Ubuntu” or “SteamOS”.
  4. The OS.get_processor_name() operate returns the identify of the CPU.
  5. RenderingServer.get_rendering_device().get_device_name() returns the identify of the GPU.

Now press F5 to save lots of the script and run the challenge. You need to now see the system data within the data label

Main pc System Specs

When you would export and run this challenge in your Steam Deck at this level, you’ll see that the system data is crammed in appropriately.
Right here’s the outcome with a local Linux construct:

Steam Deck info on Linux

And right here’s the outcome with a Home windows construct:

Steam Deck info on Windows

I’ll cowl how you can export and run this challenge on the Steam Deck in a while on this tutorial. For now, crucial factor to remove is what the Steam Deck stories as its CPU and GPU:

  • CPU: AMD Customized APU 0405
  • GPU: AMD Customized GPU 0405 (RADV VANGOGH)

Based mostly on this data, you possibly can detect in case your challenge is working on a Steam Deck. To take action, add the next operate to the system_info_label.gd script:

func _is_steam_deck() -> bool: # 1
    if RenderingServer.get_rendering_device().get_device_name().accommodates("RADV VANGOGH") 
    or OS.get_processor_name().accommodates("AMD CUSTOM APU 0405"): # 2
        return true
    else: # 3
        return false

This operate will return true if the Steam Deck is detected, and false in any other case:

  1. It is a operate named _is_steam_deck which returns a boolean worth.
  2. If the identify of the GPU accommodates the string “RADV VANGOGH” or the CPU identify accommodates the string “AMD CUSTOM APU 0405”, it returns true.
  3. In any other case, it returns false.

Now add this line to the _ready operate:

    self.textual content += "Steam Deck: " + str(_is_steam_deck()) + "n"

This can present true or false relying on if the challenge is working on a Steam Deck. Run the challenge once more to see the outcome.

Steam Deck false

On an precise Steam Deck, this will probably be true in fact!
Listed below are some strategies on what you are able to do with this data:

  • Allow gamepad help
  • Present button prompts and different graphics particular to the Steam Deck
  • Mechanically alter efficiency settings to run optimally
  • Transfer and resize UI components for higher readability
  • Collect analytics to enhance the challenge’s efficiency

Dealing with Enter

The Steam Deck has enter controls and a touchscreen. On this part you’ll learn to get the enter from the Steam Deck and use it in your challenge.

Enter Map Setup

The enter from the Steam Deck’s controller could be mapped in Godot as if you happen to had been utilizing an Xbox controller.
To begin off, check out the present actions within the enter map by deciding on Challenge ▸ Challenge Settings ▸ Enter Map.

Actions

The actions outlined within the enter map are:

  • speed up
  • brake
  • left
  • proper
  • switch_camera

For every of those actions, you’ll want so as to add a brand new gamepad occasion to help enter from a sport controller. Listed below are the mappings I’ll be utilizing:

  • speed up : Proper set off
  • brake : Left set off
  • left : Left analog stick left
  • proper : Left analog stick proper
  • switch_camera : Y button

You’ll be able to change these mappings as you favor, or add further ones. To map a brand new occasion to an motion, click on the + button subsequent to the motion’s identify.

Plus button next to accelerate

Subsequent, both press or transfer the enter you need to bind to the motion in your gamepad. When you don’t have a gamepad, you possibly can choose the occasion below Joypad Buttons or Joypad Axes. For the speed up motion for instance, you’d press the fitting set off.

Pressing right trigger

Now click on the OK button on the backside left to verify including the occasion. You’ll now see that the occasion has been added to the enter map.

Added event

Now do the identical for the opposite actions till all of them have gamepad occasions.

All events

To check if the gamepad occasions are working, run the challenge once more whereas utilizing a gamepad.

Test drive

Nice! That’s all it’s essential do to help the Steam Deck’s controller. Subsequent up is utilizing the touchscreen.

Touchscreen Enter

Though the Steam Deck has a touchscreen, it shouldn’t be the first method to work together together with your sport because of the small display measurement its decrease sensitivity in comparison with a smartphone. Nevertheless, you possibly can add easy buttons or detect movement occasions as an non-obligatory characteristic.

For example, you’ll be including a button to the nook of the display to change the digicam view.

Camera button

So as to add the button, begin by including a Button node to CanvasLayer by right-clicking the CanvasLayer node and deciding on Add Youngster Node. Subsequent, seek for “Button” within the search bar on the high, choose Button and click on the Create button so as to add it.

Add button

This could’ve added a brand new Button node under the CanvasLayer node.

Button

Choose this new button and rename it to CameraSwitchButton by right-clicking it and deciding on Rename or by urgent F2. Now swap to the 2D mode to see choice field across the button on the high left. You’ll have to zoom in to get a greater view.

Selected button

In the intervening time, there’s not a lot to see. To alter that, drag the camera_switch.png picture from the sprites folder within the FileSystem dock onto the Icon subject within the Inspector.

Drag button icon

The button will now be lots bigger, with an icon within the center.

Icon in button

To get the button to the highest proper as an alternative of the highest left, change its anchor preset to Prime Proper through the Anchor dropdown within the toolbar.

Top Right Anchor

This strikes the button to the highest proper as anticipated. To present it a small offset from the perimeters of the display, maintain down Shift and press the left arrow key in your keyboard adopted by the down arrow key. This creates a number of pixels of area from the perimeters.

Move button away from edges

To forestall the button from being pressed accidentally when urgent keyboard or gamepad button, it’s greatest to disable the main target mode of the button. You are able to do this by scrolling down within the Inspector, increasing Focus below the Management part and deciding on None from the Mode dropdown.

Change focus mode to none

Nice! All that’s left for this button is to hook up its pressed sign to the switch_camera operate of the CameraManager node. Change to the Node tab within the Inspector and double-click the pressed() sign.

Pressed signal

This opens a sign connection dialog window the place you possibly can select a operate to name when the button is pressed. Now choose the CameraManager node and click on the Decide button. This can open a listing of features that may be known as.

CameraManager Pick

Subsequent, choose the switch_camera operate and click on the OK button.

switch camera function

Again within the sign connection dialog, click on the Join button on the backside to complete the connection.
Right here’s what the switch_camera operate seems to be like:

func switch_camera() -> void:
    if birds_eye_camera.present:
        behind_car_camera.present = true
    else:
        behind_car_camera.present = false

This toggles the lively digicam between the behind the automobile digicam and the birds eye digicam. With the button all arrange, it’s time for one more check drive!
Fireplace up the challenge once more utilizing F5 and check if the button works as anticipated.

Toggle camera view

The challenge is now completed! Time to check it on an actual Steam Deck.

Exporting Builds

You’ll be creating each a Home windows and a Linux construct for the Steam Deck. This makes it straightforward to match what kind of construct will supply the most effective efficiency.
First off, choose Challenge ▸ Export… within the high menu to open the Export Presets menu.

Select Export

Now click on the Add… button on the high and add a Linux/X11 export preset.

Add linux preset

Notice: When you get an error on the backside saying “No export template discovered”, click on the Handle Export Templates hyperlink and obtain the template through the Export Template Supervisor.

Now set the Export Path to any folder in your PC, ideally a folder that syncs to the Steam Deck.

Set export path

So as to add the Home windows export preset, click on the Add… button once more and choose Home windows Desktop this time. Subsequent, choose an Export Path simply as you probably did for the Linux preset.
Now click on the Export All… button on the backside proper to export the challenge utilizing each presets. For the export mode, select Debug. This can construct each a Home windows and a Linux construct within the folders you specified.

Export all and debug

With the challenge exported, now you can check them on the Steam Deck. When you’re unsure how you can switch and run your builds to the Steam Deck, check out the Switch Sport Builds to a Steam Deck article.

Sport Efficiency

The Steam Deck comes with a nifty efficiency overlay built-in that exhibits you the way exhausting the CPU and GPU are working. By analyzing the data this overlay offers, you will get a greater understanding of how your sport is performing.

Operating the Linux Construct

To begin off, run the native Linux construct first and check if the whole lot is working appropriately. You need to be capable of management the automobile utilizing the built-in gamepad and clicking the digicam button on the display switches the digicam view. The system data ought to say you’re working the challenge on a Linux-based OS named SteamOS and the Steam Deck flag ought to be set to true.

Linux build info

Now allow the efficiency overlay by clicking the three dotted button on the backside proper of your Steam Deck and deciding on the battery icon within the Fast Entry menu. From right here, slide the Efficiency Overlay Stage to 4.

Set performance overlay

Subsequent, check out the left aspect of the display to see all of the efficiency data you might ever need.

Performance info

It may be a bit exhausting to see what’s occurring due to the background, however right here’s a fast overview from high to backside:

  • GPU: GPU utilization, temperature, clock pace and energy draw
  • CPU: CPU utilization, temperature, clock pace and energy draw
  • CPU cores: The utilization per CPU core, with its clock pace
  • VRAM: The quantity of VRAM utilized by the GPU to render the sport
  • RAM: Quantity of RAM utilized by the sport
  • BATT: The quantity of battery life left, the entire energy draw and the approximate time left earlier than the battery runs out
  • FAN: The fan pace in rotations per minute
  • FSR: Whether or not FSR (Constancy Tremendous Decision) is enabled or not
  • GAMESCOPE: The body time and body depend

An important metric out of all of those is the body time. If the inexperienced line is flat on a regular basis, then your sport will really feel easy because it’ll run at a steady 60 FPS. Nevertheless, if the inexperienced line is consistently leaping up and down, then your sport will really feel uneven and laggy. There’s no method to completely keep away from some choppiness when instantiating new scenes and whereas the shaders are compiling, however throughout the primary sport loop, the body charge ought to be steady.

To get an concept of how graphically demanding your sport is, check out the GPU clock pace. The upper the quantity, the extra demanding the sport is. The Steam Deck tends to attempt to use the least quantity of energy doable, so it clocks down its 1.6 GHz (1600MHz) GPU each time it will possibly. Within the case of the automobile sport, it tends to hover between 1050 and 1100 MHz.
To know the quantity of leeway you will have by way of graphical efficiency, you possibly can manually set the GPU clock pace through the efficiency settings. Press the three dotted button once more and scroll right down to Guide GPU Clock Management within the Efficiency part. Now test the checkbox subsequent Guide GPU Clock Management and slide GPU Clock Frequency to 1600. This can lock the GPU clock pace to its highest doable worth for optimum efficiency.

Set GPU clock 1600

When you now exit the menu and take one other take a look at the GPU clock, you’ll discover it’s now set to 1600MHz.

GPU clock 1600

The proportion above the clock pace is now way more beneficial, as this means how a lot your sport is utilizing the GPU in easy phrases. Because the automobile sport isn’t optimized in any manner, the GPU utilization is someplace between 58% and 70% more often than not, which is surprisingly excessive for such a easy sport.

The CPU utilization is less complicated to identify, as you simply want to have a look at the CPU utilization share. The upper the quantity, the extra demanding the sport is by way of CPU utilization.

CPU usage

Now exit the Linux construct of the sport because it’s time to maneuver over to the Home windows construct.

Operating the Home windows Construct

Begin up the Home windows construct and check out the system data on the high left. As a substitute exhibiting the precise OS, it says the sport is working inside Home windows. The Steam Deck flag is about to true although as anticipated.

Windows build info

The explanation why it says Home windows right here as an alternative of Linux like with the opposite construct is as a result of Home windows executables are run inside a Proton compatibility layer. Video games working like this can “assume” they’re working on a Home windows machine. Some video games run higher below Proton than their native counterparts, whereas some received’t work in any respect. It’s greatest to check out your video games completely earlier than deciding what model you need to advocate for the Steam Deck.

Now lock the GPU clock to 1600 once more and examine the efficiency of the Home windows construct.

Windows performance

The sport is working virtually similar to the Linux construct, so on this case the native Linux construct may be the best choice. It’s a good suggestion to maintain testing each varieties of builds as your sport will increase in complexity.

The place to Go From Right here?

Congratulations! You’ve arrange a Godot challenge for the Steam Deck, exported it and did some primary efficiency testing. You’ll be able to obtain the ultimate challenge on the high or backside of this tutorial.

When you’re caught, don’t hesitate to hunt assist from the Godot neighborhood by means of their Discord, boards, or different platforms. You can too attain out through the Kodeco Discord and by becoming a member of the dialogue under.
When you create one thing cool for the Steam Deck utilizing Godot, don’t overlook to share it!



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments