commit
This commit is contained in:
parent
fbc909fe22
commit
5ccf07b0f3
29
character.gd
29
character.gd
@ -1,6 +1,8 @@
|
|||||||
extends CharacterBody3D
|
extends CharacterBody3D
|
||||||
|
|
||||||
const SPEED = 5.0
|
const SPEED = 5.
|
||||||
|
const FAST_SPEED = 10.
|
||||||
|
|
||||||
const JUMP_VELOCITY = 4.5
|
const JUMP_VELOCITY = 4.5
|
||||||
|
|
||||||
# Get the gravity from the project settings to be synced with RigidBody nodes.
|
# Get the gravity from the project settings to be synced with RigidBody nodes.
|
||||||
@ -23,6 +25,9 @@ func _physics_process(delta: float):
|
|||||||
# Handle jump.
|
# Handle jump.
|
||||||
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
||||||
velocity.y = JUMP_VELOCITY
|
velocity.y = JUMP_VELOCITY
|
||||||
|
persone.animation("jump")
|
||||||
|
move_and_slide()
|
||||||
|
return
|
||||||
|
|
||||||
# Get the input direction and handle the movement/deceleration.
|
# Get the input direction and handle the movement/deceleration.
|
||||||
# As good practice, you should replace UI actions with custom gameplay actions.
|
# 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 dir: Vector3
|
||||||
|
|
||||||
|
var speed = SPEED
|
||||||
|
if Input.is_action_pressed("shift"):
|
||||||
|
speed = FAST_SPEED
|
||||||
|
|
||||||
if Input.is_action_pressed("up"):
|
if Input.is_action_pressed("up"):
|
||||||
dir = (transform.basis * direction)
|
dir = direction
|
||||||
else:
|
else:
|
||||||
dir = Vector3()
|
dir = Vector3()
|
||||||
|
|
||||||
if dir:
|
if dir:
|
||||||
var angle = direction.signed_angle_to(lookDirection, Vector3.DOWN)
|
var angle = direction.signed_angle_to(lookDirection, Vector3.DOWN)
|
||||||
|
|
||||||
|
#persone.rotation.y += angle
|
||||||
var q = lerp(persone.rotation.y, persone.rotation.y + angle, 1)
|
var q = lerp(persone.rotation.y, persone.rotation.y + angle, 1)
|
||||||
persone.rotation.y = q
|
persone.rotation.y = q
|
||||||
|
|
||||||
lookDirection = direction.normalized()
|
lookDirection = direction.normalized()
|
||||||
|
|
||||||
persone.animation("walk")
|
if is_on_floor():
|
||||||
velocity.x = dir.x * SPEED
|
if Input.is_action_pressed("shift"):
|
||||||
velocity.z = dir.z * SPEED
|
persone.animation("run")
|
||||||
|
else:
|
||||||
|
persone.animation("walk")
|
||||||
|
|
||||||
|
velocity.x = dir.x * speed
|
||||||
|
velocity.z = dir.z * speed
|
||||||
else:
|
else:
|
||||||
persone.animation("idle")
|
if is_on_floor():
|
||||||
|
persone.animation("idle")
|
||||||
|
|
||||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||||
velocity.z = move_toward(velocity.z, 0, SPEED)
|
velocity.z = move_toward(velocity.z, 0, SPEED)
|
||||||
|
|
||||||
|
@ -7,9 +7,5 @@ func _ready():
|
|||||||
pass # Replace with function body.
|
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):
|
func animation(animation: String):
|
||||||
animation_player.play(animation, .100)
|
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)
|
"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