Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

# Godot-specific ignores
.import/
.godot/
*.import
export.cfg
export_presets.cfg

Expand Down
8 changes: 4 additions & 4 deletions HexGrid.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends Spatial
extends Node3D


const TILE_MATERIALS = [
Expand All @@ -11,7 +11,7 @@ const TILE_MATERIALS = [
const TILE_SIZE := 1.0
const HEX_TILE = preload("res://HexTile.tscn")

export (int, 2, 20) var grid_size := 10
@export var grid_size := 10


func _ready() -> void:
Expand All @@ -22,10 +22,10 @@ func _generate_grid():
var tile_index := 0
for x in range(grid_size):
var tile_coordinates := Vector2.ZERO
tile_coordinates.x = x * TILE_SIZE * cos(deg2rad(30))
tile_coordinates.x = x * TILE_SIZE * cos(deg_to_rad(30))
tile_coordinates.y = 0 if x % 2 == 0 else TILE_SIZE / 2
for y in range(grid_size):
var tile = HEX_TILE.instance()
var tile = HEX_TILE.instantiate()
add_child(tile)
tile.translate(Vector3(tile_coordinates.x, 0, tile_coordinates.y))
tile_coordinates.y += TILE_SIZE
Expand Down
8 changes: 4 additions & 4 deletions HexTile.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=2 format=3 uid="uid://gw5say780o1s"]

[ext_resource path="res://unit_hex.glb" type="PackedScene" id=1]
[ext_resource type="PackedScene" uid="uid://jrar5xng2qk6" path="res://unit_hex.glb" id="1"]

[node name="HexTile" type="Spatial"]
[node name="HexTile" type="Node3D"]

[node name="unit_hex" parent="." instance=ExtResource( 1 )]
[node name="unit_hex" parent="." instance=ExtResource("1")]
14 changes: 7 additions & 7 deletions Main.tscn
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=2 format=3 uid="uid://b4yrst6fau0xu"]

[ext_resource path="res://HexGrid.gd" type="Script" id=1]
[ext_resource type="Script" path="res://HexGrid.gd" id="1"]

[node name="Main" type="Spatial"]
[node name="Main" type="Node3D"]

[node name="HexGrid" type="Spatial" parent="."]
script = ExtResource( 1 )
[node name="HexGrid" type="Node3D" parent="."]
script = ExtResource("1")

[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 0.866025, 0.5, 0, -0.5, 0.866025, 4.1, 3, 12 )
[node name="Camera" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.866025, 0.5, 0, -0.5, 0.866025, 4.1, 3, 12)
34 changes: 0 additions & 34 deletions icon.png.import

This file was deleted.

3 changes: 2 additions & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
; [section] ; section goes between []
; param=value ; assign values to parameters

config_version=4
config_version=5

[application]

config/name="Godot 3D Hex Grid Tutorial"
run/main_scene="res://Main.tscn"
config/features=PackedStringArray("4.1")
config/icon="res://icon.png"

[physics]
Expand Down
Loading