From fca412affc5ea8bc989ba9ff87acaf719856cad5 Mon Sep 17 00:00:00 2001 From: osquallo Date: Sun, 29 Jul 2018 08:28:48 +0200 Subject: [PATCH] petit fix --- scenes/Game/Character/Character.gd | 88 ++++++++++++++-------------- scenes/Game/Character/Character.tscn | 12 ++-- 2 files changed, 51 insertions(+), 49 deletions(-) diff --git a/scenes/Game/Character/Character.gd b/scenes/Game/Character/Character.gd index 0b74cc9..4eba0f1 100644 --- a/scenes/Game/Character/Character.gd +++ b/scenes/Game/Character/Character.gd @@ -62,49 +62,51 @@ func process_input(delta): func process_movement(delta): - dir.y = 0 - dir = dir.normalized() - -# vel.y += delta*GRAVITY - - var hvel = vel - hvel.y = 0 - - var target = dir - target *= MAX_SPEED - - var accel - if dir.dot(hvel) > 0: - accel = ACCEL - else: - accel = DEACCEL - - hvel = hvel.linear_interpolate(target, accel*delta) - vel.x = hvel.x - vel.z = hvel.z -# vel = move_and_slide(vel,Vector3(0,1,0), 0.05, 4, deg2rad(MAX_SLOPE_ANGLE)) - var collision_info = move_and_collide(vel * delta) - if collision_info: - vel = vel.bounce(collision_info.normal) - var obj = collision_info.collider - if obj.is_class( "RigidBody" ): - obj.sleeping = false - obj.apply_impulse( collision_info.position, -collision_info.normal*delta ) - if not obj.get_node( "MeshInstance" ).get_surface_material(0).get("albedo_color") == null: - obj.get_node( "MeshInstance" ).get_surface_material(0).albedo_color = Color( 1, 0, 1, 1 ) - get_node( "../../GUI/HUD/Jauges/douleur/ProgressBar" ).value += 0.25 - if get_node( "../../GUI/HUD/Jauges/douleur/ProgressBar" ).value >= 100: - get_node( "../../GUI/HUD/Jauges/trauma/ProgressBar" ).value += 0.25 - if get_node( "../../GUI/HUD/Jauges/trauma/ProgressBar" ).value >= 100: - get_node( "../../GUI/HUD/Jauges/oubli/ProgressBar" ).value += 0.25 -# obj.get_node( "MeshInstance" ).get_surface_material(0).albedo_color = Color( collision_info.normal ) -# if obj.has_method( "hit" ): -# obj.hit( collision_info.position, collision_info.collider_velocity ) - - -# print(str(collision_info.collider.get_class())) - - + + if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED: + dir.y = 0 + dir = dir.normalized() + + # vel.y += delta*GRAVITY + + var hvel = vel + hvel.y = 0 + + var target = dir + target *= MAX_SPEED + + var accel + if dir.dot(hvel) > 0: + accel = ACCEL + else: + accel = DEACCEL + + hvel = hvel.linear_interpolate(target, accel*delta) + vel.x = hvel.x + vel.z = hvel.z + # vel = move_and_slide(vel,Vector3(0,1,0), 0.05, 4, deg2rad(MAX_SLOPE_ANGLE)) + var collision_info = move_and_collide(vel * delta) + if collision_info: + vel = vel.bounce(collision_info.normal) + var obj = collision_info.collider + if obj.is_class( "RigidBody" ): + obj.sleeping = false + obj.apply_impulse( collision_info.position, -collision_info.normal*delta ) + if not obj.get_node( "MeshInstance" ).get_surface_material(0).get("albedo_color") == null: + obj.get_node( "MeshInstance" ).get_surface_material(0).albedo_color = Color( 1, 0, 1, 1 ) + get_node( "../../GUI/HUD/Jauges/douleur/ProgressBar" ).value += 0.25 + if get_node( "../../GUI/HUD/Jauges/douleur/ProgressBar" ).value >= 100: + get_node( "../../GUI/HUD/Jauges/trauma/ProgressBar" ).value += 0.25 + if get_node( "../../GUI/HUD/Jauges/trauma/ProgressBar" ).value >= 100: + get_node( "../../GUI/HUD/Jauges/oubli/ProgressBar" ).value += 0.25 + # obj.get_node( "MeshInstance" ).get_surface_material(0).albedo_color = Color( collision_info.normal ) + # if obj.has_method( "hit" ): + # obj.hit( collision_info.position, collision_info.collider_velocity ) + + + # print(str(collision_info.collider.get_class())) + + func _input(event): if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED: diff --git a/scenes/Game/Character/Character.tscn b/scenes/Game/Character/Character.tscn index b4eb01d..647e3ea 100644 --- a/scenes/Game/Character/Character.tscn +++ b/scenes/Game/Character/Character.tscn @@ -2,11 +2,11 @@ [ext_resource path="res://scenes/Game/Character/Character.gd" type="Script" id=1] -[sub_resource type="SphereShape" id=2] +[sub_resource type="SphereShape" id=1] radius = 0.897042 -[sub_resource type="SphereMesh" id=1] +[sub_resource type="SphereMesh" id=2] custom_aabb = AABB( 0, 0, 0, 0, 0, 0 ) radius = 1.0 @@ -15,7 +15,7 @@ radial_segments = 64 rings = 32 is_hemisphere = false -[node name="Character" type="KinematicBody"] +[node name="Character" type="KinematicBody" index="0"] transform = Transform( 1, 0, 0, 0, 0.589355, 0, 0, 0, 1, -0.0409546, 1.06519, 6.02408 ) input_ray_pickable = true @@ -55,8 +55,8 @@ _sections_unfolded = [ "Transform" ] [node name="CollisionShape" type="CollisionShape" parent="." index="1"] -transform = Transform( 0.364654, 0, 0, 0, -2.47558e-08, -0.566346, 0, 0.313738, -1.37139e-08, 0.0505983, 4.32164, 0 ) -shape = SubResource( 2 ) +transform = Transform( 0.364654, 0, 0, 0, -2.47558e-008, -0.566346, 0, 0.313738, -1.37139e-008, 0.0505983, 4.32164, 0 ) +shape = SubResource( 1 ) disabled = false _sections_unfolded = [ "Transform" ] @@ -72,7 +72,7 @@ lod_min_distance = 0.0 lod_min_hysteresis = 0.0 lod_max_distance = 0.0 lod_max_hysteresis = 0.0 -mesh = SubResource( 1 ) +mesh = SubResource( 2 ) skeleton = NodePath("..") material/0 = null