Skip to content

Commit

Permalink
Automatically scale glasses and wand to current gameboard scale
Browse files Browse the repository at this point in the history
  • Loading branch information
BastiaanOlij committed Nov 17, 2023
1 parent 064ac48 commit a1aab19
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
7 changes: 6 additions & 1 deletion example.gd/addons/tiltfive/assets/T5GlassesModel.tscn
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
[gd_scene load_steps=2 format=3 uid="uid://b1cd3jc00rhal"]
[gd_scene load_steps=3 format=3 uid="uid://b1cd3jc00rhal"]

[ext_resource type="PackedScene" uid="uid://c44ott7hdtkjs" path="res://addons/tiltfive/assets/T5-glasses.glb" id="1_22or3"]
[ext_resource type="Script" path="res://addons/tiltfive/assets/auto_scale.gd" id="2_w6vky"]

[node name="T5-glasses" instance=ExtResource("1_22or3")]
script = ExtResource("2_w6vky")

[node name="Cube" parent="." index="0"]
layers = 2
8 changes: 7 additions & 1 deletion example.gd/addons/tiltfive/assets/T5WandModel.tscn
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
[gd_scene load_steps=2 format=3 uid="uid://fipea8dbocg4"]
[gd_scene load_steps=3 format=3 uid="uid://fipea8dbocg4"]

[ext_resource type="PackedScene" uid="uid://bggv3rg34lcs6" path="res://addons/tiltfive/assets/T5-wand.glb" id="1_rqv18"]
[ext_resource type="Script" path="res://addons/tiltfive/assets/auto_scale.gd" id="2_t5vy4"]

[node name="T5-wand" instance=ExtResource("1_rqv18")]
script = ExtResource("2_t5vy4")

[node name="Roundcube_001" parent="." index="0"]
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0)
layers = 2
25 changes: 25 additions & 0 deletions example.gd/addons/tiltfive/assets/auto_scale.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
extends Node3D

var origin : T5Origin3D
var gameboard_scale : float = 1.0

func _find_origin():
var parent = get_parent()
while parent and !origin:
if parent is T5Origin3D:
origin = parent
return

parent = parent.get_parent()


# Called when the node enters the scene tree for the first time.
func _ready():
_find_origin()


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if origin and origin.gameboard_scale != gameboard_scale:
gameboard_scale = origin.gameboard_scale
scale = Vector3(gameboard_scale, gameboard_scale, gameboard_scale)

0 comments on commit a1aab19

Please sign in to comment.