diff options
author | tpart <tpart120@proton.me> | 2024-09-16 13:51:38 +0200 |
---|---|---|
committer | tpart <tpart120@proton.me> | 2024-09-16 13:53:29 +0200 |
commit | 7612bae40de7f9494ebca230965989efada60778 (patch) | |
tree | 63e193582258c469dc43ecd92fd2631fe1ab3ec9 /client/player | |
parent | 16c6235e931ac220fa8be2061df24e70dadd2a8c (diff) | |
download | hurrycurry-7612bae40de7f9494ebca230965989efada60778.tar hurrycurry-7612bae40de7f9494ebca230965989efada60778.tar.bz2 hurrycurry-7612bae40de7f9494ebca230965989efada60778.tar.zst |
Fix item holding position
Diffstat (limited to 'client/player')
-rw-r--r-- | client/player/player.gd | 11 |
1 files changed, 8 insertions, 3 deletions
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 |