You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.5 KiB
GDScript
48 lines
1.5 KiB
GDScript
extends Node3D
|
|
class_name Move
|
|
|
|
@onready var character = (get_owner() as Character)
|
|
@onready var status = (%Status as Status)
|
|
|
|
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
|
|
|
|
func _physics_process(delta):
|
|
update_on_floor(delta)
|
|
update_gravity(delta)
|
|
update_move()
|
|
|
|
character.move_and_slide()
|
|
|
|
func update_on_floor(delta):
|
|
status.is_on_floor = character.is_on_floor()
|
|
if status.is_on_floor:
|
|
if status.is_jumped_check_time > 0:
|
|
status.is_jumped_check_time -= delta
|
|
else:
|
|
status.is_jumped_check_time = 0
|
|
status.is_jumped = false
|
|
|
|
func update_gravity(delta):
|
|
if not status.is_on_floor:
|
|
character.velocity.y -= gravity * delta * status.cfg.move.gravity_scale
|
|
status.speed_y = character.velocity.y
|
|
|
|
func update_move():
|
|
var move_speed = status.cfg.move.speed * (1 + status.speed_up_rate)
|
|
var move_velocity = status.move_dir * move_speed
|
|
var skill_velocity = status.skill_dir * status.skill_move_speed
|
|
var hit_back_velocity = status.hit_back_dir * status.hit_back_speed
|
|
move_velocity += skill_velocity + hit_back_velocity
|
|
character.velocity.x = move_velocity.x
|
|
character.velocity.z = move_velocity.y
|
|
|
|
status.speed_xz = Vector2(character.velocity.x,character.velocity.z).length()
|
|
if status.is_free_turn and move_velocity.x != 0:
|
|
status.is_right = move_velocity.x > 0
|
|
|
|
func jump():
|
|
character.velocity.y = status.cfg.move.jump_velocity
|
|
status.is_jumped = true
|
|
status.is_jumped_check_time = Setting.is_jumped_check_time
|
|
status.trigger_jump = true
|