This commit is contained in:
orsolya-st
2026-06-06 16:32:52 +02:00
3 changed files with 60 additions and 2 deletions
+10 -1
View File
@@ -87,9 +87,18 @@ public class DropletMovement : MonoBehaviour
if (isDashing || isDropping) if (isDashing || isDropping)
{ {
return; return;
} // was here before
float windForce = 0f;
if (WindManager.Instance != null)
{
windForce = WindManager.Instance.CurrentWindForce;
} }
rb.linearVelocity = new Vector2(movement.x * moveSpeed, rb.linearVelocity.y); rb.linearVelocity = new Vector2(movement.x * moveSpeed + windForce, rb.linearVelocity.y);
//used to be rb.linearVelocity = new Vector2(movement.x * moveSpeed, rb.linearVelocity.y);
} }
private void OnTriggerEnter2D(Collider2D other) private void OnTriggerEnter2D(Collider2D other)
+47
View File
@@ -0,0 +1,47 @@
using UnityEngine;
using System.Collections;
public class WindManager : MonoBehaviour
{
public static WindManager Instance;
public float windStrength = 5f;
public float windDuration = 10f;
public float minTimeBetweenWind = 5f;
public float maxTimeBetweenWind = 20f;
public float CurrentWindForce { get; private set; }
void Awake()
{
Instance = this;
}
void Start()
{
StartCoroutine(WindRoutine());
}
IEnumerator WindRoutine()
{
while (true)
{
float waitTime = Random.Range(
minTimeBetweenWind,
maxTimeBetweenWind
);
yield return new WaitForSeconds(waitTime);
CurrentWindForce =
Random.value < 0.5f
? -windStrength
: windStrength;
yield return new WaitForSeconds(windDuration);
CurrentWindForce = 0f;
}
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 77a372e261eab9a4b9b6cf05e6c6e576