This commit is contained in:
Merlar 2020-02-02 09:43:17 +00:00
commit 55c65880d0
3 changed files with 19 additions and 9 deletions

View File

@ -1,14 +1,20 @@
extends Spatial extends RigidBody
class_name BodyBase class_name BodyBase
export(int) var player_id 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 on_ingame():
func _ready(): ground = get_parent().get_node("Arena").get_node("ground")
pass # Replace with function body. ingame = true
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta): func _process(delta):
# pass if ingame:
current_angle = translation.angle_to(ground.translation)
print(current_angle)

View File

@ -11,6 +11,7 @@ height = 1.48749
[node name="Torso" type="RigidBody" groups=[ [node name="Torso" type="RigidBody" groups=[
"Player", "Player",
]] ]]
transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0 )
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="TorsoCollider" type="CollisionShape" parent="."] [node name="TorsoCollider" type="CollisionShape" parent="."]

View File

@ -9,7 +9,7 @@ var _fighting_scene
var _win_screen_scene var _win_screen_scene
var _bodies : Array var _bodies : Array
var _body_count = 0 var _body_count = 0
var _body_positions = [Vector3(-30, 3, 0), Vector3(30, 3, 0), Vector3(0, 3, -30), Vector3(0, 3, 30)] var _body_positions = [Vector3(0, 5, -30), Vector3(0, 5, 30), Vector3(-30, 5, 0), Vector3(30, 5, 0)]
func _ready(): func _ready():
InGameState.player_count = 2 InGameState.player_count = 2
@ -60,8 +60,8 @@ func _switch_to_fighting(torso):
_body_build_scene.remove_child(torso) _body_build_scene.remove_child(torso)
torso.global_transform.origin = Vector3.ZERO torso.global_transform.origin = Vector3.ZERO
torso.translation += Vector3(0, 4, 0) torso.translation += _body_positions[_body_count]
torso.rotation = Vector3.ZERO torso.rotation = Vector3(90, 0, 0)
_body_count += 1 _body_count += 1
if _body_count < InGameState.player_count: if _body_count < InGameState.player_count:
@ -75,7 +75,10 @@ func _switch_to_fighting(torso):
for body in _bodies: for body in _bodies:
_fighting_scene.add_child(body) _fighting_scene.add_child(body)
body.on_ingame()
_fighting_scene.add_child(torso) _fighting_scene.add_child(torso)
torso.on_ingame()
func _switch_to_body_build(): func _switch_to_body_build():