First version of Growth added.
parent
e68ad548b6
commit
2614c2e7ab
|
|
@ -0,0 +1,39 @@
|
||||||
|
extends XROrigin3D
|
||||||
|
|
||||||
|
# Gleiches Enum zur Sicherheit
|
||||||
|
enum AgeState { BABY, CHILD, TEEN }
|
||||||
|
|
||||||
|
# Skalierungs-Faktoren (XROrigin Scale)
|
||||||
|
# < 1.0 macht dich klein (Welt wirkt riesig)
|
||||||
|
# 1.0 ist Normalgröße
|
||||||
|
var scale_baby = 0.3 # ca. 30% Größe (Baby)
|
||||||
|
var scale_child = 0.65 # ca. 65% Größe (Kind)
|
||||||
|
var scale_teen = 1.0 # 100% Größe (Teenager)
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
# Wir starten initial als Baby
|
||||||
|
apply_scale(scale_baby)
|
||||||
|
|
||||||
|
# Diese Funktion muss mit dem Signal der Uhr verbunden werden
|
||||||
|
func _on_watch_age_changed(new_age_state):
|
||||||
|
match new_age_state:
|
||||||
|
AgeState.BABY:
|
||||||
|
tween_scale(scale_baby)
|
||||||
|
AgeState.CHILD:
|
||||||
|
tween_scale(scale_child)
|
||||||
|
AgeState.TEEN:
|
||||||
|
tween_scale(scale_teen)
|
||||||
|
|
||||||
|
func tween_scale(target_scale_value: float):
|
||||||
|
# Wir nutzen Tween für einen sanften Übergang (vermeidet Übelkeit)
|
||||||
|
var tween = create_tween()
|
||||||
|
|
||||||
|
# Wir skalieren den gesamten XROrigin
|
||||||
|
# Vector3.ONE * target_scale ergibt (x, y, z) mit dem gleichen Wert
|
||||||
|
tween.tween_property(self, "scale", Vector3.ONE * target_scale_value, 0.5).set_trans(Tween.TRANS_SINE)
|
||||||
|
|
||||||
|
print("Skaliere Spieler zu: ", target_scale_value)
|
||||||
|
|
||||||
|
func apply_scale(val: float):
|
||||||
|
# Harte Skalierung ohne Animation (für den Start)
|
||||||
|
scale = Vector3.ONE * val
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
uid://due6c7nr73hxe
|
||||||
|
|
@ -0,0 +1,105 @@
|
||||||
|
extends Node3D
|
||||||
|
|
||||||
|
# Wir definieren unsere 3 Altersstufen
|
||||||
|
enum AgeState { BABY, CHILD, TEEN }
|
||||||
|
|
||||||
|
# Startalter ist BABY
|
||||||
|
var current_age = AgeState.BABY
|
||||||
|
|
||||||
|
# Referenzen zu den anderen Nodes (müssen im Inspektor zugewiesen werden)
|
||||||
|
@export var controller : XRController3D
|
||||||
|
@export var player_body : CharacterBody3D
|
||||||
|
|
||||||
|
# Referenz zum Aussehen der Uhr (für Farbänderung)
|
||||||
|
@onready var visual_mesh = $CSGMesh3D
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
# 1. Controller finden, falls nicht zugewiesen
|
||||||
|
if not controller:
|
||||||
|
# Wir gehen im Baum nach oben: Watch -> Area3D -> RightController
|
||||||
|
controller = get_parent().get_parent()
|
||||||
|
|
||||||
|
# 2. Signal verbinden
|
||||||
|
if controller:
|
||||||
|
controller.button_pressed.connect(_on_button_pressed)
|
||||||
|
print("Uhr verbunden mit Controller: ", controller.name)
|
||||||
|
else:
|
||||||
|
printerr("FEHLER: Kein Controller gefunden!")
|
||||||
|
|
||||||
|
# 3. Initiale Werte setzen (damit wir als Baby starten)
|
||||||
|
apply_age_physics()
|
||||||
|
update_visuals()
|
||||||
|
|
||||||
|
func _on_button_pressed(button_name: String):
|
||||||
|
# Input Abfrage (A/B oder X/Y je nach Controller)
|
||||||
|
match button_name:
|
||||||
|
"primary_click": # Älter werden
|
||||||
|
change_age(1)
|
||||||
|
"secondary_click": # Jünger werden
|
||||||
|
change_age(-1)
|
||||||
|
"ax_button": # Fallback
|
||||||
|
change_age(1)
|
||||||
|
"by_button": # Fallback
|
||||||
|
change_age(-1)
|
||||||
|
|
||||||
|
func change_age(direction: int):
|
||||||
|
var new_age_value = current_age + direction
|
||||||
|
|
||||||
|
# Begrenzen: Nicht jünger als Baby, nicht älter als Teen
|
||||||
|
if new_age_value < AgeState.BABY:
|
||||||
|
print("Du bist schon ein Baby!")
|
||||||
|
return
|
||||||
|
elif new_age_value > AgeState.TEEN:
|
||||||
|
print("Du bist schon erwachsen!")
|
||||||
|
return
|
||||||
|
|
||||||
|
# Wenn gültig, Alter ändern
|
||||||
|
current_age = new_age_value
|
||||||
|
print("Alter geändert zu: ", AgeState.keys()[current_age])
|
||||||
|
|
||||||
|
# Physik und Aussehen aktualisieren
|
||||||
|
apply_age_physics()
|
||||||
|
update_visuals()
|
||||||
|
|
||||||
|
func apply_age_physics():
|
||||||
|
# Sicherheitscheck
|
||||||
|
if not player_body:
|
||||||
|
printerr("ACHTUNG: PlayerBody ist im Inspektor nicht zugewiesen!")
|
||||||
|
return
|
||||||
|
|
||||||
|
# Hier ändern wir die Min/Max Werte des XRToolsPlayerBody
|
||||||
|
match current_age:
|
||||||
|
AgeState.BABY:
|
||||||
|
# Baby: Sehr klein
|
||||||
|
# Min muss niedrig sein für Krabbeln/Ducken
|
||||||
|
player_body.player_height_min = 0.2
|
||||||
|
# Max begrenzt die Kapselhöhe auf ca. 60cm
|
||||||
|
player_body.player_height_max = 0.6
|
||||||
|
|
||||||
|
AgeState.CHILD:
|
||||||
|
# Kind: Mittelgroß
|
||||||
|
player_body.player_height_min = 0.4
|
||||||
|
# Max begrenzt auf ca. 1.30m
|
||||||
|
player_body.player_height_max = 1.3
|
||||||
|
|
||||||
|
AgeState.TEEN:
|
||||||
|
# Teenager: Standard VR Werte (Groß)
|
||||||
|
player_body.player_height_min = 0.6
|
||||||
|
# Max ist hoch genug für jeden Erwachsenen (2.5m ist Standard-Puffer)
|
||||||
|
player_body.player_height_max = 2.5
|
||||||
|
|
||||||
|
func update_visuals():
|
||||||
|
# Ändert die Farbe der Uhr zur Bestätigung
|
||||||
|
if visual_mesh and visual_mesh.material:
|
||||||
|
# Falls das Material nicht unique ist, erstellen wir eine Kopie, damit nicht alle Meshes die Farbe ändern
|
||||||
|
if not visual_mesh.material.resource_local_to_scene:
|
||||||
|
visual_mesh.material = visual_mesh.material.duplicate()
|
||||||
|
|
||||||
|
var mat = visual_mesh.material as StandardMaterial3D
|
||||||
|
match current_age:
|
||||||
|
AgeState.BABY:
|
||||||
|
mat.albedo_color = Color.HOT_PINK # Baby
|
||||||
|
AgeState.CHILD:
|
||||||
|
mat.albedo_color = Color.ORANGE # Kind
|
||||||
|
AgeState.TEEN:
|
||||||
|
mat.albedo_color = Color.GRAY # Teen
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
uid://ceqc6auge0rjs
|
||||||
19
player.tscn
19
player.tscn
|
|
@ -1,13 +1,20 @@
|
||||||
[gd_scene load_steps=6 format=3 uid="uid://srkkei4i3bwx"]
|
[gd_scene load_steps=9 format=3 uid="uid://srkkei4i3bwx"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://njx823gyk04n" path="res://addons/godot-xr-tools/hands/scenes/highpoly/left_hand.tscn" id="2_hqtel"]
|
[ext_resource type="PackedScene" uid="uid://njx823gyk04n" path="res://addons/godot-xr-tools/hands/scenes/highpoly/left_hand.tscn" id="2_hqtel"]
|
||||||
[ext_resource type="PackedScene" uid="uid://raeeicvvindd" path="res://addons/godot-xr-tools/hands/scenes/highpoly/right_hand.tscn" id="2_i3pqv"]
|
[ext_resource type="PackedScene" uid="uid://raeeicvvindd" path="res://addons/godot-xr-tools/hands/scenes/highpoly/right_hand.tscn" id="2_i3pqv"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bl2nuu3qhlb5k" path="res://addons/godot-xr-tools/functions/movement_direct.tscn" id="2_sweqy"]
|
[ext_resource type="PackedScene" uid="uid://bl2nuu3qhlb5k" path="res://addons/godot-xr-tools/functions/movement_direct.tscn" id="2_sweqy"]
|
||||||
[ext_resource type="PackedScene" uid="uid://diyu06cw06syv" path="res://addons/godot-xr-tools/player/player_body.tscn" id="4_2hs0m"]
|
[ext_resource type="PackedScene" uid="uid://diyu06cw06syv" path="res://addons/godot-xr-tools/player/player_body.tscn" id="4_2hs0m"]
|
||||||
|
[ext_resource type="Script" uid="uid://ceqc6auge0rjs" path="res://ChronoWatch.gd" id="4_sweqy"]
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_hqtel"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_hqtel"]
|
||||||
size = Vector3(0.1, 0.1, 0.2)
|
size = Vector3(0.1, 0.1, 0.2)
|
||||||
|
|
||||||
|
[sub_resource type="SphereMesh" id="SphereMesh_hqtel"]
|
||||||
|
radius = 0.05
|
||||||
|
height = 0.1
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_sweqy"]
|
||||||
|
|
||||||
[node name="Player" type="XROrigin3D"]
|
[node name="Player" type="XROrigin3D"]
|
||||||
|
|
||||||
[node name="Camera" type="XRCamera3D" parent="."]
|
[node name="Camera" type="XRCamera3D" parent="."]
|
||||||
|
|
@ -37,4 +44,14 @@ hand_offset_mode = 4
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="RightController/Area3D"]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="RightController/Area3D"]
|
||||||
shape = SubResource("BoxShape3D_hqtel")
|
shape = SubResource("BoxShape3D_hqtel")
|
||||||
|
|
||||||
|
[node name="Watch" type="Node3D" parent="RightController/Area3D" node_paths=PackedStringArray("controller", "player_body")]
|
||||||
|
script = ExtResource("4_sweqy")
|
||||||
|
controller = NodePath("../..")
|
||||||
|
player_body = NodePath("../../../PlayerBody")
|
||||||
|
|
||||||
|
[node name="CSGMesh3D" type="CSGMesh3D" parent="RightController/Area3D/Watch"]
|
||||||
|
mesh = SubResource("SphereMesh_hqtel")
|
||||||
|
material = SubResource("StandardMaterial3D_sweqy")
|
||||||
|
|
||||||
[node name="PlayerBody" parent="." instance=ExtResource("4_2hs0m")]
|
[node name="PlayerBody" parent="." instance=ExtResource("4_2hs0m")]
|
||||||
|
player_height_rate = 20.0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue