Skip to content

Commit

Permalink
Downscale HUD when only one local input
Browse files Browse the repository at this point in the history
  • Loading branch information
toberge committed Jun 8, 2024
1 parent 81ca5bc commit 6180cea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
9 changes: 5 additions & 4 deletions Assets/Prefabs/Input/Player.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ MonoBehaviour:
maxRadius: 5
minRadius: 1
collisionOffset: 0.3
lookSensitivity: 5
InputManager: {fileID: 0}
--- !u!1 &345906872987025452
GameObject:
Expand Down Expand Up @@ -1111,7 +1112,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_ConstrainProportionsScale: 1
m_Children:
- {fileID: 6629533919243205533}
- {fileID: 8513528357214213258}
Expand All @@ -1120,7 +1121,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 400, y: 225}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!210 &4673711381798312254
Expand Down Expand Up @@ -1171,7 +1172,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -319.1, y: -165}
m_AnchoredPosition: {x: 80.9, y: 60}
m_SizeDelta: {x: 150.42, y: 150}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3455060718068446809
Expand Down Expand Up @@ -1541,7 +1542,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -203.1, y: -194.9}
m_AnchoredPosition: {x: 196.9, y: 30.1}
m_SizeDelta: {x: 253.6, y: 60}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1876285937171696916
Expand Down
13 changes: 8 additions & 5 deletions Assets/Scripts/UI/PlayerHUDController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,25 +127,28 @@ void Start()
ammoBar.material = ammoCapacityMaterial;
ammoCapacityMaterial.SetFloat("_Arc2", 0);

healthBarScaleX = healthBar.transform.localScale.x;
healthBar.color = healthMax;
healthTextPosition = healthText.transform.localPosition;
defaultCrosshairScale = crosshair.localScale;

originalChipY = chipBox.anchoredPosition.y;
// Anchor to top right if there's only one player.
// This keeps the chip counter from conflicting with the timer
if (!MatchController.Singleton || PlayerInputManagerController.Singleton.LocalPlayerInputs.Count() == 1)
{
// Anchor to top right if there's only one player.
// This keeps the chip counter from conflicting with the timer
chipBox.anchorMin = Vector2.one;
chipBox.anchorMax = Vector2.one;
originalChipX = -chipBox.sizeDelta.x / 2f - 10;
// Also scale down the health bar stuff
hudParent.localScale = .6f * Vector3.one;
}
else
{
originalChipX = 0;
}
chipBox.anchoredPosition = new Vector2(originalChipX, -originalChipY);

healthBarScaleX = healthBar.transform.localScale.x;
healthBar.color = healthMax;
healthTextPosition = healthText.transform.localPosition;
}

public void SetSpeedLines(Vector3 velocity)
Expand Down

0 comments on commit 6180cea

Please sign in to comment.