|
|
@@ -19,10 +19,19 @@ onready var camera = get_node("CameraOrbit") |
|
|
|
onready var interactCast = get_node("InteractRayCast") |
|
|
|
onready var anim = get_node("Casual2_Female/AnimationPlayer") |
|
|
|
|
|
|
|
# internal |
|
|
|
|
|
|
|
var interactables := [] |
|
|
|
var pushed_object |
|
|
|
|
|
|
|
func _process(delta): |
|
|
|
# attack input |
|
|
|
if Controller.player_input_enabled and is_on_floor() and Input.is_action_just_pressed("interact"): |
|
|
|
try_interact() |
|
|
|
if Controller.player_input_enabled and is_on_floor(): |
|
|
|
if Input.is_action_just_pressed("interact"): |
|
|
|
try_interact_pressed() |
|
|
|
|
|
|
|
if Input.is_action_just_released("interact"): |
|
|
|
try_interact_released() |
|
|
|
|
|
|
|
for area in $TouchableArea.get_overlapping_areas(): |
|
|
|
try_touch(area) |
|
|
@@ -62,7 +71,7 @@ func _physics_process (delta): |
|
|
|
vel.z = dir.z * walkSpeed |
|
|
|
|
|
|
|
# jump input |
|
|
|
if Input.is_action_pressed("jump") and is_on_floor(): |
|
|
|
if can_jump(): |
|
|
|
vel.y = jumpForce |
|
|
|
else: |
|
|
|
vel.x = 0 |
|
|
@@ -80,8 +89,14 @@ func _physics_process (delta): |
|
|
|
else: |
|
|
|
anim.play("RecieveHit") |
|
|
|
|
|
|
|
# move along the current velocity |
|
|
|
var previous_vel = vel |
|
|
|
# move pushed object first if there is one |
|
|
|
if pushed_object: |
|
|
|
var object_vel = pushed_object.move_and_slide(vel, Vector3.UP, true, 1, deg2rad(30)) |
|
|
|
vel.x = object_vel.x |
|
|
|
vel.z = object_vel.z |
|
|
|
|
|
|
|
# move along the current velocity |
|
|
|
vel = move_and_slide(vel, Vector3.UP, true, 4, deg2rad(30)) |
|
|
|
|
|
|
|
"debug for water" |
|
|
@@ -116,11 +131,33 @@ func try_touch(area): |
|
|
|
area.on_touch(self) |
|
|
|
|
|
|
|
# called when we press the interact button |
|
|
|
func try_interact(): |
|
|
|
# is the ray cast colliding with an enemy? |
|
|
|
func try_interact_pressed(): |
|
|
|
# play the animation |
|
|
|
anim.stop() |
|
|
|
anim.play("Idle") |
|
|
|
|
|
|
|
for area in $InteractorArea.get_overlapping_areas(): |
|
|
|
# play the animation |
|
|
|
anim.stop() |
|
|
|
anim.play("Idle") |
|
|
|
if area.has_method("on_interact"): |
|
|
|
area.on_interact() |
|
|
|
if area.has_method("on_interact_pressed"): |
|
|
|
interactables.push_back(area) |
|
|
|
area.on_interact_pressed(self) |
|
|
|
|
|
|
|
# called when we release the interact button |
|
|
|
func try_interact_released(): |
|
|
|
# play the animation |
|
|
|
anim.stop() |
|
|
|
anim.play("Idle") |
|
|
|
|
|
|
|
for interactable in interactables: |
|
|
|
if interactable.has_method("on_interact_released"): |
|
|
|
interactable.on_interact_released(self) |
|
|
|
|
|
|
|
interactables.clear() |
|
|
|
|
|
|
|
func start_pushing(body): |
|
|
|
pushed_object = body |
|
|
|
|
|
|
|
func stop_pushing(body): |
|
|
|
pushed_object = null |
|
|
|
|
|
|
|
func can_jump(): |
|
|
|
return pushed_object == null and Input.is_action_pressed("jump") and is_on_floor() |