summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortpart <tpart120@proton.me>2024-09-16 13:51:38 +0200
committertpart <tpart120@proton.me>2024-09-16 13:53:29 +0200
commit7612bae40de7f9494ebca230965989efada60778 (patch)
tree63e193582258c469dc43ecd92fd2631fe1ab3ec9
parent16c6235e931ac220fa8be2061df24e70dadd2a8c (diff)
downloadhurrycurry-7612bae40de7f9494ebca230965989efada60778.tar
hurrycurry-7612bae40de7f9494ebca230965989efada60778.tar.bz2
hurrycurry-7612bae40de7f9494ebca230965989efada60778.tar.zst
Fix item holding position
-rw-r--r--client/map/items/food_processor.gd3
-rw-r--r--client/map/items/plate.gd4
-rw-r--r--client/player/player.gd11
3 files changed, 13 insertions, 5 deletions
diff --git a/client/map/items/food_processor.gd b/client/map/items/food_processor.gd
index c082a741..05b783c1 100644
--- a/client/map/items/food_processor.gd
+++ b/client/map/items/food_processor.gd
@@ -83,3 +83,6 @@ func finish():
static func base_position() -> Vector3:
return Vector3(0., 0.4, 0.)
+
+static func height() -> float:
+ return .3
diff --git a/client/map/items/plate.gd b/client/map/items/plate.gd
index eb9ee4b5..28fd3f46 100644
--- a/client/map/items/plate.gd
+++ b/client/map/items/plate.gd
@@ -44,5 +44,5 @@ func setup_sounds():
take_sound.setup([preload("res://map/items/sounds/plate_take.ogg")])
put_sound.setup([preload("res://map/items/sounds/plate_put.ogg")])
-static func base_position() -> Vector3:
- return Vector3(0., 0.05, 0.)
+static func height() -> float:
+ return .05
diff --git a/client/player/player.gd b/client/player/player.gd
index 6af1dd0c..cf5adcc6 100644
--- a/client/player/player.gd
+++ b/client/player/player.gd
@@ -47,7 +47,8 @@ var character_idx: int
var _anim_angle: float = 0.0
-const HAND_BASE_POSITION: Vector3 = Vector3(0, .25, .4)
+var hand_base_position: Vector3 = DEFAULT_HAND_BASE_POSITION
+const DEFAULT_HAND_BASE_POSITION: Vector3 = Vector3(0, .425, .4)
func _init(_id: int, new_name: String, pos: Vector2, new_character_idx: int, new_game: Game):
add_child(movement_base)
@@ -59,7 +60,8 @@ func _init(_id: int, new_name: String, pos: Vector2, new_character_idx: int, new
game = new_game
username = new_name
- hand_base.position = HAND_BASE_POSITION
+ hand_base.name = "HandBase"
+ hand_base.position = hand_base_position
movement_base.add_child(hand_base)
movement_base.add_child(chat_bubble)
@@ -91,6 +93,9 @@ func update_username_tag(state):
func set_item(i: Item):
if hand != null: hand.remove()
+ if i != null:
+ @warning_ignore("static_called_on_instance")
+ hand_base_position = DEFAULT_HAND_BASE_POSITION - Vector3(0., i.height() * 0.5, 0.)
character.holding = i != null
hand = i
if hand != null: hand.owned_by = hand_base
@@ -127,7 +132,7 @@ func pass_to(player: Player):
func _process(delta):
_anim_angle = fmod(_anim_angle + delta, TAU)
- hand_base.position.y = HAND_BASE_POSITION.y + 0.05 * sin(_anim_angle * 3)
+ hand_base.position.y = hand_base_position.y + 0.05 * sin(_anim_angle * 3)
position_anim = G.interpolate(position_anim, position_, delta * 10)
rotation_anim = G.interpolate_angle(rotation_anim, rotation_, delta * 10)
movement_base.position.x = position_anim.x