diff --git a/assets/creatures/ra/basemesh_humanoid_animated.glb b/assets/creatures/ra/basemesh_humanoid_animated.glb index 302fc1f..97eaab6 100644 Binary files a/assets/creatures/ra/basemesh_humanoid_animated.glb and b/assets/creatures/ra/basemesh_humanoid_animated.glb differ diff --git a/project.godot b/project.godot index ac8c544..b61ce97 100644 --- a/project.godot +++ b/project.godot @@ -127,6 +127,16 @@ reset_camera={ "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":67,"unicode":0,"echo":false,"script":null) ] } +sprint={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777237,"unicode":0,"echo":false,"script":null) + ] +} +toggle_sprint={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777241,"unicode":0,"echo":false,"script":null) + ] +} [khanat] diff --git a/ressources/scripts/entity.gd b/ressources/scripts/entity.gd index 9cf582d..25f2221 100644 --- a/ressources/scripts/entity.gd +++ b/ressources/scripts/entity.gd @@ -24,7 +24,7 @@ func move( m_movment ): spatial.translate( m_movment ) child.move_and_slide( spatial.translation*10.0, Vector3( 0.0, 1.0, 0.0 ), true ) spatial.queue_free() - + func turn( m_rotation ): if $model: diff --git a/scenes/game/game.tscn b/scenes/game/game.tscn index 7f63ec5..24f2f9c 100644 --- a/scenes/game/game.tscn +++ b/scenes/game/game.tscn @@ -24,8 +24,8 @@ noise = SubResource( 1 ) [sub_resource type="ShaderMaterial" id=3] resource_local_to_scene = true shader = ExtResource( 5 ) -shader_param/iTime = 60.0352 -shader_param/iFrame = 1402 +shader_param/iTime = 1086.03 +shader_param/iFrame = 83264 shader_param/COVERAGE = 0.5 shader_param/THICKNESS = 25.0 shader_param/ABSORPTION = 1.031 diff --git a/scenes/player/player.gd b/scenes/player/player.gd index 80a6551..079d5bc 100644 --- a/scenes/player/player.gd +++ b/scenes/player/player.gd @@ -4,18 +4,26 @@ onready var player = $model/ra onready var camera = $model/ra/spring_arm onready var skin = $model/ra/model -export var max_speed: = 6.0 +export var sprint_speed = 10.0 +export var max_speed: = 12.0 export var move_speed: = 5.0 export var gravity = -100.0 export var jump_impulse = 25 export(float, 0.1, 20.0, 0.1) var rotation_speed_factor: = 0.01 var velocity: = Vector3.ZERO +var is_sprinting = false func _ready(): # $camera.make_current() $model/ra/spring_arm/camera.make_current() + +func _input( event ): + + if event.is_action_pressed( "toggle_sprint" ): + is_sprinting = not is_sprinting + func _process( delta ): var input_direction: = self.get_input_direction() @@ -41,8 +49,17 @@ func _process( delta ): velocity = self.calculate_velocity(velocity, move_direction, delta) velocity = player.move_and_slide(velocity, Vector3.UP, true) - if move_direction: - $model/ra/model/AnimationPlayer.play( "walk" ) + if input_direction: + if not input_direction.z == 0.0: + if self.is_sprinting(): + $model/ra/model/AnimationPlayer.play( "run" ) + else: + $model/ra/model/AnimationPlayer.play( "walk" ) + elif input_direction.x > 0.0: + $model/ra/model/AnimationPlayer.play( "strafe_right" ) + elif input_direction.x < 0.0: + $model/ra/model/AnimationPlayer.play( "strafe_left" ) + else: $model/ra/model/AnimationPlayer.play( "idle" ) @@ -59,7 +76,11 @@ func calculate_velocity( move_direction: Vector3, delta: float ) -> Vector3: - var velocity_new := move_direction * move_speed + var velocity_new := move_direction + if self.is_sprinting(): + velocity_new *= sprint_speed + else: + velocity_new *= move_speed if velocity_new.length() > max_speed: velocity_new = velocity_new.normalized() * max_speed velocity_new.y = velocity_current.y + gravity * delta @@ -89,7 +110,12 @@ func load_creature( filename ): $model/ra/model/metarig/Skeleton/body.set( "blend_shapes/Pregnant", self.creature.female_pregnant ) $model/ra/model/metarig/Skeleton/body.get_surface_material( 0 ).set_shader_param( "albedo", self.creature.color ) - +func is_sprinting(): + if (not self.is_sprinting and Input.is_action_pressed( "sprint" )) \ + or (self.is_sprinting and not Input.is_action_pressed( "sprint" )) \ + : + return true + return false func rotate_camera_arm( p_axis, p_angle_degree ): $model/ra/spring_arm.rotate( p_axis, p_angle_degree )