Converting to Godot and Understanding Differences
Sorry for the long break I have been very busy with college and other events the last couple months hopefully we will return to at least one post a month. Also I hope everyone one had a good new years unfortunately I missed the 1 year anniversary of the website but I do have something planned that will maybe be done in the future.

Recently with the problems we have seen with the trustworthiness of Unity, many have escaped to the game engine that is Godot. Today I am going to take a look at it, compare it with Unity, and look at some code examples with it.

 

Understanding Godot

Godot is an open-source, cross-platform game engine that boasts a user-friendly interface and a powerful set of features. Developed by a passionate community, Godot has gained traction due to its transparency, active support, and the absence of licensing fees. With support for 2D and 3D game development, Godot provides a robust foundation for developers to bring their visions to life.

Godot Engine on Steam

Differences

There are many differences between Unity and Godot. Some of them are:

Licensing:

Unity uses a freemium model, this allows developers to use the free version for small projects and pay for larger projects or for more features. While Godot is completely open source which means no features are locked behind a paywall.

Language:

Unity uses C# for its scripting but also supports JavaScript and Boo. While Godot was designed with GDScript. GDScript is its own custom language that is meant to be easy and emulate beginner languages. Godot also supports visual scripting.

Interfaces:

Unity is widely known in the community and is used as a professional software. It has established layouts and workflows which may be a lot for new users. While Godot’s interface is intuitive and user-friendly. It was designed to be approachable with its drag-and-drop system and clean layout. This simplicity can be a significant advantage for those who are new to game dev.

Some Real Examples

Starting off with a menu.

These buttons are nice but now we have to add code in.

 extends control
# Called when the node enters the scene tree for the first time.
func _ready():
	$VBoxContainer2/StartButton.grab_focus()


func _on_start_button_pressed():
	get_tree().change_scene_to_file("res://Game.tscn")


func _on_quit_button_pressed():
	get_tree().quit()


func _on_option_button_pressed():
	get_tree().change_scene_to_file("res://Menus/options.tscn")

 

First the extends control line indicates that the script uses the control class, this class is used for UI elements.

The ready function grabs the focus of the arrow keys/controller to the start button allowing people to control the button select with just arrow keys or a controller.

The on_start_button_pressed function switches to the game scene when you press start.

The on_quit_button_pressed function quits the game when you press it.

The on_option_button_pressed function switches to the options menu when you press it.

This section is mainly intended to handle the main menu and switch around to different scenes.

 

Classes

Here I made an example with some classes in godot, while they do not really do anything, they lay the groundwork to future work.

 

extends Node3D


class_name Company

# define important variables used -- More will be added in the future when more is implemented (such as employees and game creation)

var isAI: bool = true
var isOwned: bool = false

var preferedGenre: String
var companyOwner: String
var companyName: String

var infamy: float = 0.0

var money: int = 0
var fans: int = 0


# Runs when a game is started

func _init():
if(isAI):
generate()
#seed will be set to company name digitized + ingame time + the game's seed value.
seed(companyName.hash()+111)


# Will randomly generate stats for the company generated. (Name generation still needs to be done, other generation will be added as features are added)

func generate():

seed(Time.get_unix_time_from_system())


# Decides if the company starts as a 'big player'
if(randi()% 10 == 1):
fans = randi() % 30
infamy = randi() % 11
money = randi() % 10000 + 10000
else:
money = randi() % 10000 + 1000

# Will be run by game manager if the company is AI.
func AITick():
# Will check here to make sure the isAI state hasn't changed.
if(isAI):
return
# Sends error to log if mismatch is found
assert('Mismatch found in ' + companyName + ' where gamestate considers company AI but company doesnt consider itself AI')

# Events that only affect the company, will run in Random Tick.
func compEvent():
return

# Random Tick decides events that company runs (unix time will change to something better when multiplayer is added to prevent desyncs.
func randomTick():
seed(companyName.hash()+111+Time.get_unix_time_from_system())
if(randi()% 51 == 1):
compEvent()
return
return

The second section outlines a class structure for managing fictional companies in a game environment, setting up variables and functions for generating company stats and managing AI behavior.

This class allows you to create companies easily and with scalability.

Overall

GDScript, Godot’s scripting language, plays a crucial role in making these interactions seamless. While it may be different from languages used in other engines, its syntax is designed to be beginner-friendly. The custom GDScript language, paired with Godot’s drag-and-drop system, creates a user-friendly environment for both new and experienced game developers.

 

No Comments

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
Previous
Next