debug level and character added
This commit is contained in:
parent
f48d6575cb
commit
554d81b912
35 changed files with 8472 additions and 0 deletions
44
scripts/player.gd
Normal file
44
scripts/player.gd
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
extends CharacterBody3D
|
||||
|
||||
@onready var animated_mesh = $GobotSkin
|
||||
|
||||
const SPEED = 5.0
|
||||
const JUMP_VELOCITY = 4.5
|
||||
|
||||
func _ready() -> void:
|
||||
pass
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
animated_mesh.idle()
|
||||
|
||||
# Add the gravity.
|
||||
if not is_on_floor():
|
||||
velocity += get_gravity() * delta
|
||||
animated_mesh.fall()
|
||||
|
||||
# Handle jump.
|
||||
if Input.is_action_just_pressed("ui_accept"):
|
||||
print("jump")
|
||||
animated_mesh.run()
|
||||
|
||||
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
||||
velocity.y = JUMP_VELOCITY
|
||||
|
||||
# Get the input direction and handle the movement/deceleration.
|
||||
# As good practice, you should replace UI actions with custom gameplay actions.
|
||||
var input_dir := Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
||||
|
||||
if input_dir.length() > 0 and is_on_floor():
|
||||
animated_mesh.run()
|
||||
if input_dir.length() > 0 and not is_on_floor():
|
||||
animated_mesh.fall()
|
||||
|
||||
var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||
if direction:
|
||||
velocity.x = direction.x * SPEED
|
||||
velocity.z = direction.z * SPEED
|
||||
else:
|
||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||
velocity.z = move_toward(velocity.z, 0, SPEED)
|
||||
|
||||
move_and_slide()
|
||||
Loading…
Add table
Add a link
Reference in a new issue