Add a basic animation
This commit is contained in:
parent
5a57b1dfd0
commit
6fe6c614d3
3917
scenes/player.tscn
3917
scenes/player.tscn
File diff suppressed because one or more lines are too long
|
@ -34,7 +34,7 @@ albedo_texture = ExtResource("2_ptvmb")
|
|||
transform = Transform3D(-0.952625, -0.00130936, -0.304143, -0.00131338, 0.999999, -0.00019133, 0.304143, 0.00021718, -0.952626, 0, 0, 0)
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||
transform = Transform3D(-0.866023, -0.433016, 0.250001, 0, 0.499998, 0.866027, -0.500003, 0.749999, -0.43301, 0, 0, 0)
|
||||
transform = Transform3D(-0.866024, -0.433016, 0.250001, 2.14494e-08, 0.499998, 0.866027, -0.500003, 0.749999, -0.43301, 0, 0, 0)
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
extends CharacterBody3D
|
||||
|
||||
@onready var camera_mount = $camera_mount
|
||||
@onready var annimation_player = $visuals/mixamo_base/AnimationPlayer
|
||||
const SPEED = 5.0
|
||||
const JUMP_VELOCITY = 4.5
|
||||
|
||||
|
@ -29,9 +30,13 @@ func _physics_process(delta):
|
|||
var input_dir = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
||||
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||
if direction:
|
||||
if annimation_player.current_animation != "walking":
|
||||
annimation_player.play("walking")
|
||||
velocity.x = direction.x * SPEED
|
||||
velocity.z = direction.z * SPEED
|
||||
else:
|
||||
if annimation_player.current_animation != "idle":
|
||||
annimation_player.play("idle")
|
||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||
velocity.z = move_toward(velocity.z, 0, SPEED)
|
||||
|
||||
|
|
Loading…
Reference in New Issue