commit
This commit is contained in:
parent
fbc909fe22
commit
5ccf07b0f3
27
character.gd
27
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:
|
||||
if is_on_floor():
|
||||
persone.animation("idle")
|
||||
|
||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||
velocity.z = move_toward(velocity.z, 0, SPEED)
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
]
|
||||
}
|
||||
|
BIN
tmp/throw.glb
Normal file
BIN
tmp/throw.glb
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user