Skip to content

Commit

Permalink
Changed position usage to localPosition for text & letter effects
Browse files Browse the repository at this point in the history
  • Loading branch information
RhenaudTheLukark committed Jan 29, 2024
1 parent 0cf2e8c commit 38626aa
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Assets/Scripts/Text/TextEffect/RotatingEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected override void UpdateInternal() {
RectTransform rt = textMan.letters[i].image.GetComponent<RectTransform>();
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;
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Text/TextEffect/ShakeEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
2 changes: 1 addition & 1 deletion Assets/Scripts/Text/TextEffect/TextEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
4 changes: 2 additions & 2 deletions Assets/Scripts/Text/TextEffect/TwitchEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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<RectTransform>();
rt.position += (Vector3)positions[selectedChar];
rt.localPosition += (Vector3)positions[selectedChar];
}

private int GetNextWigTime() { return avgWigFrames + Mathf.RoundToInt(wigFrameVariety * (Random.value * 2 - 1)); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion Assets/Scripts/Text/TextEffectLetter/ShakeEffectLetter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion Assets/Scripts/Text/TextEffectLetter/TextEffectLetter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
4 changes: 2 additions & 2 deletions Assets/Scripts/Text/TextEffectLetter/TwitchEffectLetter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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)); }
Expand Down

0 comments on commit 38626aa

Please sign in to comment.