#Animation Controller issue
1 messages · Page 1 of 1 (latest)
Iirc an empty state has no motion at all and doesn't write defaults
So transitioning to it would not change anything visually
If you want to control a fade, an easy way to do it is to have one state that has just a keyframe for 0 alpha, and another state that has just a keyframe for 100% alpha
The transition itself is the fade in that situation
ohh okeyy yepp makes sense .. and what about trigger part then ? shall i remove or not
You're not using animation triggers at all, as far as I can see
Play() method jumps to a state directly, skipping any animation transitions
It works if you have a "fade in" animation and a "fade out" animation, but not if you have two states with just the one destination keyframe each as I described above
There's many different ways to do something this simple
'''cs using UnityEngine;
using TMPro;
public class ScoreManager : MonoBehaviour
{
public TextMeshProUGUI scoreTextPlayer1;
public TextMeshProUGUI scoreTextPlayer2;
public GameObject scorePopupPrefab; // Prefab for score pop-up animation
public Transform canvasTransform; // Reference to the Canvas transform
private int scorePlayer1 = 0;
private int scorePlayer2 = 0;
public void Player1Scores()
{
scorePlayer1++;
scoreTextPlayer1.text = scorePlayer1.ToString();
// Show a score pop-up animation
ShowScorePopup("Player 1 Scores!", new Vector3(0, 100, 0)); // Adjust position as needed
}
public void Player2Scores()
{
scorePlayer2++;
scoreTextPlayer2.text = scorePlayer2.ToString();
// Show a score pop-up animation
ShowScorePopup("Player 2 Scores!", new Vector3(0, 100, 0)); // Adjust position as needed
}
void ShowScorePopup(string message, Vector3 position)
{
GameObject popup = Instantiate(scorePopupPrefab, canvasTransform);
TextMeshProUGUI popupText = popup.GetComponent<TextMeshProUGUI>();
popupText.text = message;
popup.transform.localPosition = position;
// Trigger the animation
Animator animator = popup.GetComponent<Animator>();
if (animator != null)
{
animator.Play("ScorePopupAnimation");
}
Destroy(popup, 1.5f); // Destroy the pop-up after 1.5 seconds
}
} '''animator.Play()? i have is that what u talking about
Format code blocks with
```cs
code here
```
yeahh ik new to it nah so havent explored that much but have got that Coroutine idea too .. but this time want to do once with animation