Test and refine carrying item code.

This commit is contained in:
blujai831 2025-03-29 02:44:10 -07:00
parent 09b25cf945
commit 3463e09994
No known key found for this signature in database
GPG Key ID: DDC31A0363AA5E66
4 changed files with 48 additions and 7 deletions

View File

@ -1180,7 +1180,7 @@ func _on_put_down_state_tick(delta: float) -> void:
_do_standard_motion(delta)
var target_displacement := (
0.25*height*Vector3.UP +
0.75*width*Vector3.FORWARD
1.5*width*Vector3.FORWARD
)
if !_carrying:
force_change_state(&'idle')
@ -1197,13 +1197,21 @@ func _on_put_down_state_tick(delta: float) -> void:
func _on_put_down_state_stop() -> void:
if _carrying:
_carrying.reparent(get_parent())
_carrying.process_mode = PROCESS_MODE_INHERIT
var thunk := func (what: Node3D) -> void:
what.reparent(get_parent())
what.process_mode = PROCESS_MODE_INHERIT
thunk.call_deferred(_carrying)
func _on_pick_up_state_start() -> void:
if _carrying:
_carrying.process_mode = PROCESS_MODE_DISABLED
_carrying.reparent(self)
var thunk := func (what: Node3D) -> void:
if _carrying == what:
if what is RigidBody3D:
what.linear_velocity = Vector3.ZERO
what.angular_velocity = Vector3.ZERO
what.process_mode = PROCESS_MODE_DISABLED
what.reparent(self)
thunk.call_deferred(_carrying)
else:
force_change_state(&'idle')
@ -1211,7 +1219,7 @@ func _on_pick_up_state_tick(delta: float) -> void:
_do_standard_motion(delta)
var target_displacement := (
0.5*height*Vector3.UP +
0.5*width*Vector3.FORWARD
width*Vector3.FORWARD
)
if !_carrying:
force_change_state(&'idle')
@ -1234,6 +1242,8 @@ func _on_idle_while_holding_state_tick(delta: float) -> void:
force_change_state(&'jump-while-holding')
elif !impetus.is_zero_approx():
state = &'walk-while-holding'
elif action1_impetus || action2_impetus:
state = &'put-down'
func _on_walk_while_holding_state_tick(delta: float) -> void:
_do_standard_motion(delta)

File diff suppressed because one or more lines are too long

9
test/pick_up_item.gd Normal file
View File

@ -0,0 +1,9 @@
extends RigidBody3D
func _ready() -> void:
body_entered.connect(_on_body_entered)
func _on_body_entered(body: PhysicsBody3D) -> void:
if body is Character:
if body.action2_impetus:
body.pick_up(self)

1
test/pick_up_item.gd.uid Normal file
View File

@ -0,0 +1 @@
uid://dotkfe7cs5010