Test and refine carrying item code.
This commit is contained in:
parent
09b25cf945
commit
3463e09994
|
@ -1180,7 +1180,7 @@ func _on_put_down_state_tick(delta: float) -> void:
|
||||||
_do_standard_motion(delta)
|
_do_standard_motion(delta)
|
||||||
var target_displacement := (
|
var target_displacement := (
|
||||||
0.25*height*Vector3.UP +
|
0.25*height*Vector3.UP +
|
||||||
0.75*width*Vector3.FORWARD
|
1.5*width*Vector3.FORWARD
|
||||||
)
|
)
|
||||||
if !_carrying:
|
if !_carrying:
|
||||||
force_change_state(&'idle')
|
force_change_state(&'idle')
|
||||||
|
@ -1197,13 +1197,21 @@ func _on_put_down_state_tick(delta: float) -> void:
|
||||||
|
|
||||||
func _on_put_down_state_stop() -> void:
|
func _on_put_down_state_stop() -> void:
|
||||||
if _carrying:
|
if _carrying:
|
||||||
_carrying.reparent(get_parent())
|
var thunk := func (what: Node3D) -> void:
|
||||||
_carrying.process_mode = PROCESS_MODE_INHERIT
|
what.reparent(get_parent())
|
||||||
|
what.process_mode = PROCESS_MODE_INHERIT
|
||||||
|
thunk.call_deferred(_carrying)
|
||||||
|
|
||||||
func _on_pick_up_state_start() -> void:
|
func _on_pick_up_state_start() -> void:
|
||||||
if _carrying:
|
if _carrying:
|
||||||
_carrying.process_mode = PROCESS_MODE_DISABLED
|
var thunk := func (what: Node3D) -> void:
|
||||||
_carrying.reparent(self)
|
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:
|
else:
|
||||||
force_change_state(&'idle')
|
force_change_state(&'idle')
|
||||||
|
|
||||||
|
@ -1211,7 +1219,7 @@ func _on_pick_up_state_tick(delta: float) -> void:
|
||||||
_do_standard_motion(delta)
|
_do_standard_motion(delta)
|
||||||
var target_displacement := (
|
var target_displacement := (
|
||||||
0.5*height*Vector3.UP +
|
0.5*height*Vector3.UP +
|
||||||
0.5*width*Vector3.FORWARD
|
width*Vector3.FORWARD
|
||||||
)
|
)
|
||||||
if !_carrying:
|
if !_carrying:
|
||||||
force_change_state(&'idle')
|
force_change_state(&'idle')
|
||||||
|
@ -1234,6 +1242,8 @@ func _on_idle_while_holding_state_tick(delta: float) -> void:
|
||||||
force_change_state(&'jump-while-holding')
|
force_change_state(&'jump-while-holding')
|
||||||
elif !impetus.is_zero_approx():
|
elif !impetus.is_zero_approx():
|
||||||
state = &'walk-while-holding'
|
state = &'walk-while-holding'
|
||||||
|
elif action1_impetus || action2_impetus:
|
||||||
|
state = &'put-down'
|
||||||
|
|
||||||
func _on_walk_while_holding_state_tick(delta: float) -> void:
|
func _on_walk_while_holding_state_tick(delta: float) -> void:
|
||||||
_do_standard_motion(delta)
|
_do_standard_motion(delta)
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -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)
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dotkfe7cs5010
|
Loading…
Reference in New Issue