From ba8689916b2235f1554825380d70a038dc7a247f Mon Sep 17 00:00:00 2001 From: mathias Date: Sun, 2 Feb 2020 10:28:45 +0100 Subject: [PATCH] Changed the rotations in loading screen and ingame. First implementation for rolly tolly toy. --- BodyParts/BodyBase/BodyBase.gd | 18 ++++++++++++------ BodyParts/BodyBase/BodyBase.tscn | 1 + Controllers/GameStateController.gd | 5 ++++- project.godot | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/BodyParts/BodyBase/BodyBase.gd b/BodyParts/BodyBase/BodyBase.gd index f48b502..691e7cd 100644 --- a/BodyParts/BodyBase/BodyBase.gd +++ b/BodyParts/BodyBase/BodyBase.gd @@ -1,14 +1,20 @@ -extends Spatial +extends RigidBody class_name BodyBase export(int) var player_id +var ingame : bool = false +var ground : Spatial +var current_angle : float -# Called when the node enters the scene tree for the first time. -func _ready(): - pass # Replace with function body. +func on_ingame(): + ground = get_parent().get_node("Arena").get_node("ground") + ingame = true + # Called every frame. 'delta' is the elapsed time since the previous frame. -#func _process(delta): -# pass +func _process(delta): + if ingame: + current_angle = translation.angle_to(ground.translation) + print(current_angle) diff --git a/BodyParts/BodyBase/BodyBase.tscn b/BodyParts/BodyBase/BodyBase.tscn index 8a6aeb7..4169730 100644 --- a/BodyParts/BodyBase/BodyBase.tscn +++ b/BodyParts/BodyBase/BodyBase.tscn @@ -11,6 +11,7 @@ height = 1.48749 [node name="Torso" type="RigidBody" groups=[ "Player", ]] +transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0 ) script = ExtResource( 1 ) [node name="TorsoCollider" type="CollisionShape" parent="."] diff --git a/Controllers/GameStateController.gd b/Controllers/GameStateController.gd index fe7a455..cfaea40 100644 --- a/Controllers/GameStateController.gd +++ b/Controllers/GameStateController.gd @@ -61,7 +61,7 @@ func _switch_to_fighting(torso): torso.global_transform.origin = Vector3.ZERO torso.translation += Vector3(0, 4, 0) - torso.rotation = Vector3.ZERO + torso.rotation = Vector3(90, 0, 0) _body_count += 1 if _body_count < InGameState.player_count: @@ -75,7 +75,10 @@ func _switch_to_fighting(torso): for body in _bodies: _fighting_scene.add_child(body) + body.on_ingame() + _fighting_scene.add_child(torso) + torso.on_ingame() func _switch_to_body_build(): diff --git a/project.godot b/project.godot index e1ed397..baa8981 100644 --- a/project.godot +++ b/project.godot @@ -9,7 +9,7 @@ config_version=4 _global_script_classes=[ { -"base": "Spatial", +"base": "RigidBody", "class": "BodyBase", "language": "GDScript", "path": "res://BodyParts/BodyBase/BodyBase.gd"