Skip to content

Commit

Permalink
Anomaly No. 23: modify ghost blowing motion
Browse files Browse the repository at this point in the history
  • Loading branch information
Prown0 committed Dec 17, 2024
1 parent 6691fee commit 0a2e62f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
4 changes: 3 additions & 1 deletion 302/Assets/Prefabs/Anomaly23/ghost.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -777,9 +777,11 @@ MonoBehaviour:
speedInit: 1
speedDelta: 5
durationChase: 25
durationBlow: 5
durationBlow: 8
timeAudioStart: 3
durationFade: 3
numRotate: 240
speedBlow: 20
--- !u!82 &3035267094544484457
AudioSource:
m_ObjectHideFlags: 0
Expand Down
2 changes: 1 addition & 1 deletion 302/Assets/Scripts/SCH_Random.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public double LogNormalDist(double mu, double sigma)
}

// 정규 분포
public double NormalDist(double mu = 0.0, double sigma = 0.0)
public double NormalDist(double mu = 0.0, double sigma = 1.0)
{
double u1, u2, z, zz;

Expand Down
50 changes: 38 additions & 12 deletions 302/Assets/Scripts/SpecificAnomalyManager/Anomaly23_Ghost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class Anomaly23_Ghost : SCH_AnomalyObject
public float durationBlow;
public float timeAudioStart;
public float durationFade;
public int numRotate;
public float speedBlow;

// 애니메이터
private Animator _animator;
Expand Down Expand Up @@ -176,12 +178,12 @@ public override bool ResetAnomaly()
{
bool res = base.ResetAnomaly();

_audioSource.enabled = false;
Log("Reset audio source success");

Log("Call `BlowAsync` asynchronously");
StartCoroutine(BlowAsync());

Log("Call `FadeAudioAsync` asynchronously");
StartCoroutine(FadeAudioAsync());

return res;
}

Expand Down Expand Up @@ -218,18 +220,42 @@ private IEnumerator FadeAudioAsync()
private IEnumerator BlowAsync()
{
SCH_Random random = new SCH_Random();
Vector3 originStart = transform.position;
Vector3 origin;
float timeStart = Time.time;
float time;
float time = 0.0f;

yield return new WaitForSeconds(0.1f);

while ((time = Time.time - timeStart) < durationBlow) {
float scale = (float)(random.LogNormalDist(0.0, 1.0) * 1.5);

transform.rotation = Random.rotation;
transform.localScale = new Vector3(scale, scale, scale);
yield return null;

yield return new WaitForSeconds(0.1f);
for (int i = 1; i <= numRotate; i++) {
Vector3 position;
Quaternion a;
Quaternion b;

origin = originStart + Vector3.up * time / durationBlow;
do {
position = new Vector3(
(float)random.NormalDist(),
(float)random.NormalDist(),
(float)random.NormalDist()
);
position += origin - transform.position;
} while (position.magnitude == 0.0f);

a = transform.rotation;
b = transform.rotation;
b.SetLookRotation(position, position);

while ((time = Time.time - timeStart) < durationBlow / numRotate * i) {
float scale = 1.0f - time / durationBlow;
float t = time / durationBlow * numRotate % 1.0f;

transform.localScale = new Vector3(scale, scale, scale);
transform.rotation = Quaternion.Lerp(a, b, t);
transform.Translate(Vector3.forward * speedBlow * Time.deltaTime);

yield return null;
}
}

Destroy(gameObject);
Expand Down

0 comments on commit 0a2e62f

Please sign in to comment.