From 38626aac665de63346daf63ca9e0e2a83077e960 Mon Sep 17 00:00:00 2001 From: RhenaudTheLukark Date: Mon, 29 Jan 2024 21:20:18 +0100 Subject: [PATCH] Changed position usage to localPosition for text & letter effects --- Assets/Scripts/Text/TextEffect/RotatingEffect.cs | 2 +- Assets/Scripts/Text/TextEffect/ShakeEffect.cs | 2 +- Assets/Scripts/Text/TextEffect/TextEffect.cs | 2 +- Assets/Scripts/Text/TextEffect/TwitchEffect.cs | 4 ++-- Assets/Scripts/Text/TextEffectLetter/RotatingEffectLetter.cs | 2 +- Assets/Scripts/Text/TextEffectLetter/ShakeEffectLetter.cs | 2 +- Assets/Scripts/Text/TextEffectLetter/TextEffectLetter.cs | 2 +- Assets/Scripts/Text/TextEffectLetter/TwitchEffectLetter.cs | 4 ++-- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Assets/Scripts/Text/TextEffect/RotatingEffect.cs b/Assets/Scripts/Text/TextEffect/RotatingEffect.cs index c2251181a..d41377866 100644 --- a/Assets/Scripts/Text/TextEffect/RotatingEffect.cs +++ b/Assets/Scripts/Text/TextEffect/RotatingEffect.cs @@ -18,7 +18,7 @@ protected override void UpdateInternal() { RectTransform rt = textMan.letters[i].image.GetComponent(); Vector2 oldPosition = positions[i]; positions[i] = new Vector2(intensity * -Mathf.Sin(iDiv), intensity * Mathf.Cos(iDiv)); - rt.position += (Vector3)(positions[i] - oldPosition); + rt.localPosition += (Vector3)(positions[i] - oldPosition); } sinTimer += Time.deltaTime; diff --git a/Assets/Scripts/Text/TextEffect/ShakeEffect.cs b/Assets/Scripts/Text/TextEffect/ShakeEffect.cs index 170438ef4..ba406483e 100644 --- a/Assets/Scripts/Text/TextEffect/ShakeEffect.cs +++ b/Assets/Scripts/Text/TextEffect/ShakeEffect.cs @@ -20,7 +20,7 @@ protected override void UpdateInternal() { float random = Random.value * 2.0f * Mathf.PI; Vector2 oldPosition = positions[i]; positions[i] = new Vector2(Mathf.Sin(random) * intensity, Mathf.Cos(random) * intensity); - rt.position += (Vector3)(positions[i] - oldPosition); + rt.localPosition += (Vector3)(positions[i] - oldPosition); } } } \ No newline at end of file diff --git a/Assets/Scripts/Text/TextEffect/TextEffect.cs b/Assets/Scripts/Text/TextEffect/TextEffect.cs index 572dc06bb..3f09281f0 100644 --- a/Assets/Scripts/Text/TextEffect/TextEffect.cs +++ b/Assets/Scripts/Text/TextEffect/TextEffect.cs @@ -22,6 +22,6 @@ public void UpdateEffects() { ~TextEffect() { for (int i = 0; i < positions.Count; i++) if (textMan != null && textMan.letters[i].image != null) - textMan.letters[i].image.transform.position -= (Vector3)positions[i]; + textMan.letters[i].image.transform.localPosition -= (Vector3)positions[i]; } } \ No newline at end of file diff --git a/Assets/Scripts/Text/TextEffect/TwitchEffect.cs b/Assets/Scripts/Text/TextEffect/TwitchEffect.cs index dd540c1cf..a7b549356 100644 --- a/Assets/Scripts/Text/TextEffect/TwitchEffect.cs +++ b/Assets/Scripts/Text/TextEffect/TwitchEffect.cs @@ -25,7 +25,7 @@ protected override void UpdateInternal() { // Move back last character if (updateCount == 0 && selectedChar >= 0 && selectedChar < textMan.letters.Count && rt) { - rt.position -= (Vector3)positions[selectedChar]; + rt.localPosition -= (Vector3)positions[selectedChar]; positions[selectedChar] = new Vector2(); } @@ -39,7 +39,7 @@ protected override void UpdateInternal() { selectedChar = Random.Range(0, textMan.letters.Count); positions[selectedChar] = new Vector2(Mathf.Sin(random) * intensity, Mathf.Cos(random) * intensity); rt = textMan.letters[selectedChar].image.GetComponent(); - rt.position += (Vector3)positions[selectedChar]; + rt.localPosition += (Vector3)positions[selectedChar]; } private int GetNextWigTime() { return avgWigFrames + Mathf.RoundToInt(wigFrameVariety * (Random.value * 2 - 1)); } diff --git a/Assets/Scripts/Text/TextEffectLetter/RotatingEffectLetter.cs b/Assets/Scripts/Text/TextEffectLetter/RotatingEffectLetter.cs index 242bc717d..71f225217 100644 --- a/Assets/Scripts/Text/TextEffectLetter/RotatingEffectLetter.cs +++ b/Assets/Scripts/Text/TextEffectLetter/RotatingEffectLetter.cs @@ -19,6 +19,6 @@ protected override void UpdateInternal() { float oldYPos = yPos; xPos = intensity * -Mathf.Sin(iDiv); yPos = intensity * Mathf.Cos(iDiv); - rt.position += new Vector3(xPos - oldXPos, yPos - oldYPos, 0); + rt.localPosition += new Vector3(xPos - oldXPos, yPos - oldYPos, 0); } } \ No newline at end of file diff --git a/Assets/Scripts/Text/TextEffectLetter/ShakeEffectLetter.cs b/Assets/Scripts/Text/TextEffectLetter/ShakeEffectLetter.cs index 794efb8fc..38c5305c0 100644 --- a/Assets/Scripts/Text/TextEffectLetter/ShakeEffectLetter.cs +++ b/Assets/Scripts/Text/TextEffectLetter/ShakeEffectLetter.cs @@ -20,6 +20,6 @@ protected override void UpdateInternal() { float oldYPos = yPos; xPos = Mathf.Sin(random) * intensity; yPos = Mathf.Cos(random) * intensity; - rt.position += new Vector3(xPos - oldXPos, yPos - oldYPos, 0); + rt.localPosition += new Vector3(xPos - oldXPos, yPos - oldYPos, 0); } } \ No newline at end of file diff --git a/Assets/Scripts/Text/TextEffectLetter/TextEffectLetter.cs b/Assets/Scripts/Text/TextEffectLetter/TextEffectLetter.cs index f488b4464..05d679464 100644 --- a/Assets/Scripts/Text/TextEffectLetter/TextEffectLetter.cs +++ b/Assets/Scripts/Text/TextEffectLetter/TextEffectLetter.cs @@ -15,6 +15,6 @@ protected TextEffectLetter(Letter letter) { ~TextEffectLetter() { if (letter) - rt.position -= new Vector3(xPos, yPos, 0); + rt.localPosition -= new Vector3(xPos, yPos, 0); } } \ No newline at end of file diff --git a/Assets/Scripts/Text/TextEffectLetter/TwitchEffectLetter.cs b/Assets/Scripts/Text/TextEffectLetter/TwitchEffectLetter.cs index ee57d160e..c9d115a31 100644 --- a/Assets/Scripts/Text/TextEffectLetter/TwitchEffectLetter.cs +++ b/Assets/Scripts/Text/TextEffectLetter/TwitchEffectLetter.cs @@ -19,7 +19,7 @@ public TwitchEffectLetter(Letter letter, float intensity = 2.0f, int step = 0) : protected override void UpdateInternal() { if (updateCount == 0) { - rt.position -= new Vector3(xPos, yPos); + rt.localPosition -= new Vector3(xPos, yPos); xPos = yPos = 0; } @@ -32,7 +32,7 @@ protected override void UpdateInternal() { float random = Random.value * 2.0f * Mathf.PI; xPos = Mathf.Sin(random) * intensity; yPos = Mathf.Cos(random) * intensity; - rt.position += new Vector3(xPos, yPos); + rt.localPosition += new Vector3(xPos, yPos); } private int GetNextWigTime() { return avgWigFrames + Mathf.RoundToInt(wigFrameVariety * (Random.value * 2 - 1)); }