Fix bug with gravity being lost after menu

This commit is contained in:
karl 2020-02-01 22:44:22 +01:00
parent 1858ca6288
commit 14b60c1e02
3 changed files with 11 additions and 7 deletions

View File

@ -25,8 +25,6 @@ signal start_fight()
# Called when the node enters the scene tree for the first time.
func _ready():
_default_grav = PhysicsServer.area_get_param(get_viewport().find_world().get_space(), PhysicsServer.AREA_PARAM_GRAVITY)
PhysicsServer.area_set_param(get_viewport().find_world().get_space(), PhysicsServer.AREA_PARAM_GRAVITY, 0)
_torso = get_node(torsoPath) as RigidBody
_camera = get_node(cameraPath) as Camera
_rayCast = get_node(rayCastPath) as RayCast
@ -34,6 +32,9 @@ func _ready():
func _process(delta):
# TODO: Would be nicer to just disable gravity, but then it can't be re-enabled...
_torso.translation = Vector3.ZERO
if _viewRot:
var mouse_pos = get_viewport().get_mouse_position()
@ -122,6 +123,4 @@ func delete_body_part():
func _on_Start_pressed():
PhysicsServer.area_set_param(get_viewport().find_world().get_space(), PhysicsServer.AREA_PARAM_GRAVITY, _default_grav)
emit_signal("start_fight", _torso)

View File

@ -52,12 +52,17 @@ func _switch_to_win(player_id):
func _switch_to_fighting(torso):
_body_build_scene.remove_child(torso)
torso.global_transform.origin = Vector3.ZERO
torso.translation += Vector3(0, 3, 0)
torso.rotation = Vector3(0, 0, 0)
torso.rotation = Vector3.ZERO
_switch_scene(_fighting_scene, "fight_scene")
_fighting_scene.add_child(torso)
torso.axis_lock_linear_x = false
torso.axis_lock_linear_y = false
torso.axis_lock_linear_z = false
func _switch_to_body_build():
_switch_scene(_body_build_scene, "body_build")

View File

@ -4,5 +4,5 @@ var bodyparts : Dictionary
# Called when the node enters the scene tree for the first time.
func _ready():
bodyparts["Arm"] = load("res://BodyParts/Arm.tscn")
bodyparts["Humanleg"] = load("res://BodyParts/HumanLeg.tscn")
bodyparts["Human Arm"] = load("res://BodyParts/HumanArm.tscn")
bodyparts["Human Leg"] = load("res://BodyParts/HumanLeg.tscn")