Skip to content

Commit 8bc41ec

Browse files
committed
fix pickup spawning + add bobbing animation
1 parent 9563fae commit 8bc41ec

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

Assets/Prefabs/Pickups/ChainLightningEffect.prefab

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ MonoBehaviour:
4949
m_EditorClassIdentifier:
5050
_lineRenderer: {fileID: 6000012}
5151
_lightningDisplayDuration: 0.15
52+
_bobAmplitude: 0.08
53+
_bobFrequency: 0.5
5254
--- !u!212 &6000004
5355
SpriteRenderer:
5456
m_ObjectHideFlags: 0

Assets/Prefabs/Pickups/ChainLightningPickup.prefab

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ MonoBehaviour:
4848
m_EditorClassIdentifier:
4949
_pickupSound: {fileID: 8300000, guid: 9f38fc745c8b64043b4a6a8d9ab8deab, type: 3}
5050
_scoreValue: 100
51-
_effectDuration: 60
51+
_effectDuration: 10
5252
_effectText: Chain lightning!
5353
_effectPrefab: {fileID: 6000001, guid: d4e5f6078190a2b3c4d5e6f70891a3b4, type: 3}
5454
_damage: 15
@@ -149,7 +149,7 @@ BoxCollider2D:
149149
m_SpriteTilingProperty:
150150
border: {x: 0, y: 0, z: 0, w: 0}
151151
pivot: {x: 0.5, y: 0.5}
152-
oldSize: {x: 1, y: 1}
152+
oldSize: {x: 0.84375, y: 0.5625}
153153
newSize: {x: 1, y: 1}
154154
adaptiveTilingThreshold: 0.5
155155
drawMode: 0

Assets/Scenes/BattleScene.unity

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11508,7 +11508,7 @@ MonoBehaviour:
1150811508
- {fileID: 3306419623360918530, guid: c62e469089fde4fc98d1c3363f2ea177, type: 3}
1150911509
- {fileID: 3306419623360918530, guid: d109130e8f6de4b86a470d567292aa28, type: 3}
1151011510
- {fileID: 3306419623360918530, guid: 6cde6a2c228dc40d0b42ba0b19ca2fc3, type: 3}
11511-
- {fileID: 3306419623360918530, guid: e5f6078190a2b3c4d5e6f70891a3b4c5, type: 3}
11511+
- {fileID: 7000001, guid: e5f6078190a2b3c4d5e6f70891a3b4c5, type: 3}
1151211512
_startingPickupPrefab: {fileID: 0}
1151311513
_startingPickupOffset: {x: 2, y: 0, z: 0}
1151411514
_levelUpUI: {fileID: 3736684284675310825}

Assets/Scripts/Pickups/ChainLightningEffect.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ public class ChainLightningEffect : MonoBehaviour
2222
[Tooltip("How long the lightning line is visible in seconds.")]
2323
private float _lightningDisplayDuration = 0.5f;
2424

25+
[SerializeField]
26+
[Tooltip("Vertical bobbing amplitude above the player (world units).")]
27+
private float _bobAmplitude = 0.08f;
28+
29+
[SerializeField]
30+
[Tooltip("Bobbing speed (cycles per second).")]
31+
private float _bobFrequency = 0.5f;
32+
33+
private float _baseLocalY;
34+
2535
/// <summary>
2636
/// Configure the effect. Call after instantiating, before the effect runs.
2737
/// </summary>
@@ -51,10 +61,21 @@ public void ExtendDuration(float extraSeconds)
5161

5262
private void Start()
5363
{
64+
_baseLocalY = transform.localPosition.y;
5465
_expirationTime = Time.time + _duration;
5566
_effectCoroutine = StartCoroutine(EffectLoop());
5667
}
5768

69+
private void Update()
70+
{
71+
// Frequency in Hz (cycles per second); 2*PI converts to radians per second
72+
float radiansPerSecond = _bobFrequency * 2f * Mathf.PI;
73+
float bob = _bobAmplitude * Mathf.Sin(Time.time * radiansPerSecond);
74+
var pos = transform.localPosition;
75+
pos.y = _baseLocalY + bob;
76+
transform.localPosition = pos;
77+
}
78+
5879
private void OnDisable()
5980
{
6081
if (_effectCoroutine != null)

Assets/Scripts/Pickups/ChainLightningPickup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ protected override void OnCollect(Player player)
5757

5858
protected override string GetEffectText()
5959
{
60-
return "Chain lightning!";
60+
return "Seer sees all!";
6161
}
6262
}

0 commit comments

Comments
 (0)