ADD ajout du sprint et des animation de déplacements latéraux.
This commit is contained in:
parent
0edfbd21c0
commit
7978318bf7
5 changed files with 44 additions and 8 deletions
Binary file not shown.
|
@ -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]
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
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 )
|
||||
|
|
Loading…
Reference in a new issue