pull/2/head
Sascha 2024-05-22 11:22:38 +07:00
parent d8b04d0295
commit daa6c9bcfc
4 changed files with 35085 additions and 98 deletions

File diff suppressed because it is too large Load Diff

@ -57,3 +57,8 @@ attack={
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(115, 16),"global_position":Vector2(119, 57),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
]
}
block={
"deadzone": 0.5,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(108, 13),"global_position":Vector2(112, 54),"factor":1.0,"button_index":2,"canceled":false,"pressed":true,"double_click":false,"script":null)
]
}

File diff suppressed because one or more lines are too long

@ -11,6 +11,7 @@ var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
var jumping := false
var attacks := ["1h_slice_diagonal","1h_slice_horizontal","1h_attack_chop"]
var last_floor := true
var blocking := false
@onready var spring_arm := $SpringArm3D
@onready var model := $Rig
@ -25,32 +26,47 @@ func _physics_process(delta: float) -> void:
model.rotation.y = lerp_angle(model.rotation.y, spring_arm.rotation.y, rotation_speed * delta)
func _unhandled_input(event: InputEvent) -> void:
#move camera
if event is InputEventMouseMotion:
spring_arm.rotation.x -= event.relative.y * mouse_sensitivity
spring_arm.rotation_degrees.x = clamp(spring_arm.rotation_degrees.x, -90.0, 30.0)
spring_arm.rotation.y -= event.relative.x * mouse_sensitivity
#attack
if event.is_action_pressed("attack"):
anim_state.travel(attacks.pick_random())
if blocking:
anim_state.travel("Block_Attack")
else:
anim_state.travel(attacks.pick_random())
#block
if Input.is_action_just_pressed("block"):
blocking = true
if Input.is_action_just_released("block"):
blocking = false
anim_tree.set("parameters/conditions/blocking", blocking)
anim_tree.set("parameters/conditions/not_blocking", !blocking)
#jump
if is_on_floor() and Input.is_action_just_pressed("jump"):
velocity.y = jump_speed
jumping = true
anim_tree.set("parameters/conditions/grounded", false)
anim_tree.set("parameters/conditions/jumping", jumping)
# We just hit the floor after being in the air
if is_on_floor() and not last_floor:
jumping = false
anim_tree.set("parameters/conditions/grounded", true)
last_floor = is_on_floor()
# We're in the air, but we didn't jump
if not is_on_floor() and not jumping:
anim_state.travel("Jump_Idle")
anim_tree.set("parameters/conditions/grounded", false)
anim_tree.set("parameters/conditions/jumping", jumping)
last_floor = is_on_floor()
func get_move_input(delta: float) -> void:
var vy = velocity.y
velocity.y = 0
var input = Input.get_vector("left", "right", "forward", "back")
var dir = Vector3(input.x, 0, input.y).rotated(Vector3.UP, spring_arm.rotation.y)
if blocking:
dir = Vector3.ZERO
velocity = lerp(velocity, dir * speed, acceleration * delta)
var vl = velocity * model.transform.basis
anim_tree.set("parameters/IWR/blend_position", Vector2(vl.x, -vl.z) / speed)