diff --git a/character.gd b/character.gd index a03f791..6f5eb0a 100644 --- a/character.gd +++ b/character.gd @@ -1,6 +1,8 @@ extends CharacterBody3D -const SPEED = 5.0 +const SPEED = 5. +const FAST_SPEED = 10. + const JUMP_VELOCITY = 4.5 # Get the gravity from the project settings to be synced with RigidBody nodes. @@ -23,6 +25,9 @@ func _physics_process(delta: float): # Handle jump. if Input.is_action_just_pressed("ui_accept") and is_on_floor(): velocity.y = JUMP_VELOCITY + persone.animation("jump") + move_and_slide() + return # Get the input direction and handle the movement/deceleration. # As good practice, you should replace UI actions with custom gameplay actions. @@ -32,24 +37,36 @@ func _physics_process(delta: float): var dir: Vector3 + var speed = SPEED + if Input.is_action_pressed("shift"): + speed = FAST_SPEED + if Input.is_action_pressed("up"): - dir = (transform.basis * direction) + dir = direction else: dir = Vector3() if dir: var angle = direction.signed_angle_to(lookDirection, Vector3.DOWN) + #persone.rotation.y += angle var q = lerp(persone.rotation.y, persone.rotation.y + angle, 1) persone.rotation.y = q lookDirection = direction.normalized() - persone.animation("walk") - velocity.x = dir.x * SPEED - velocity.z = dir.z * SPEED + if is_on_floor(): + if Input.is_action_pressed("shift"): + persone.animation("run") + else: + persone.animation("walk") + + velocity.x = dir.x * speed + velocity.z = dir.z * speed else: - persone.animation("idle") + if is_on_floor(): + persone.animation("idle") + velocity.x = move_toward(velocity.x, 0, SPEED) velocity.z = move_toward(velocity.z, 0, SPEED) diff --git a/persone.gd b/persone.gd index d80c248..a28fd47 100644 --- a/persone.gd +++ b/persone.gd @@ -7,9 +7,5 @@ func _ready(): pass # Replace with function body. -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - pass - func animation(animation: String): animation_player.play(animation, .100) diff --git a/project.godot b/project.godot index 1e74668..265345e 100644 --- a/project.godot +++ b/project.godot @@ -37,3 +37,8 @@ back={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":0,"echo":false,"script":null) ] } +shift={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} diff --git a/throw.res b/throw.res new file mode 100644 index 0000000..d7fa9c3 Binary files /dev/null and b/throw.res differ diff --git a/tmp/throw.glb b/tmp/throw.glb new file mode 100644 index 0000000..d5d401b Binary files /dev/null and b/tmp/throw.glb differ