petit fix
This commit is contained in:
parent
d83058a3f7
commit
fca412affc
2 changed files with 51 additions and 49 deletions
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue