본문 바로가기

프로그래밍/게임개발

Godot Engine 사용기 1

 

 

https://godotengine.org/

 

Godot Engine - Free and open source 2D and 3D game engine

Godot provides a huge set of common tools, so you can just focus on making your game without reinventing the wheel.

godotengine.org

 

유니티가 올해에 요금제 개편을 요구하는 등의 불안정성 때문에, 다른 엔진이 어떤게 있나 알아보다 GODOT 이라는 엔진을 알게 되고 사용해보려한다. 우선 가장 큰 차이로 느껴지는건 Unity의 실행속도에 비해 매우 빠르고 가볍다. 기능도 그러할지는 사용해봐야 알것이다. 고돗은 특이하게도 GDScript라는 본인들만의 스크립트를 사용한다. 내부 에디터를 이용해서 접근할 수 있고 파이썬, javascript와 비슷한 문법이라고 소개하고 있다. 재밌는 점은 직접 다운 받을 수도 있지만 스팀이나 에픽게임즈에서 다운 받을 수 있다.

 

1. Node 시스템

유니티는 Scene에 Object를 배치하고 각 Object들은 Component를 가진다. 유니티와는 다르게 Godot Engine에서는 Scene도 Object도 요소들도 Node라고 지칭한다. 유니티 화면과 비슷해 보이지만 Scene에 해당하는 부분이 따로 없고 사진에서는 Level이 Scene을 의미하고 다른 Player역시 Node이며 Prefab처럼 따로 접근 가능하다.

 

2. 컴포넌트에 접근하기

get_node("PlayerImage")는 Player가 가지고 있는 PlayerImage 컴포넌트에 접근하는 방법이다.

편하게 하기 위해 $PlayerImage와 동일하다. 변수명이 길때는 그냥 drag drop도 가능하다.

 

3. 이동 구현

extends Node2D

var speed = 500

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	position = Vector2(300, 100)


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	var direction = Input.get_vector("left","right","up","down")
	position += direction * speed * delta

 

4. 자료형 할당

var speed: int = 500
#할당된 변수를 int로 한다.
var speed: := 500
#할당된 변수에 해당하는 자료형이어야한다.