med-material / Whack_A_Mole_VR

Whack-A-Mole in VR
MIT License
3 stars 16 forks source link

WallManager: Use transition for wall and moles. #201

Open bastianilso opened 2 years ago

bastianilso commented 2 years ago

After the in-game count-down, wallmanager generates the Whack-A-Mole wall and shows it immediately. An aesthetic improvement would be to let this transition be more gradual.

In total this animation should take less than 500ms.

introduce-transition gif

Xav1204 commented 2 years ago

@bastianilso I'm making my tests for the transition and his duration. I tried to find the place in the code where we can define the countdown time but I didn't find it. Can you tell me where I can change this time please. Here a picture of the time that I want to change: image

bastianilso commented 2 years ago

@Xav1204 This is about transitioning the wall and the moles. Why do you need to change the countdown time? I don't recognize the screenshot you have taken a picture of, sorry.

The wall is generated by WallManager.cs in line 443 and the moles are generated in line 408.

For reference, the animation I show above from Trail it is created by the following function from GameLevel.cs:

    IEnumerator SpawnTargets(GameObject[] objsToSpawn)
    {
        float t = TargetSpawnDelay;

        spawnSound.Play();
        for (int i = 0; i < objsToSpawn.Length; i++)
        {
            if (objsToSpawn != null && objsToSpawn[i] != null)
            {
                objsToSpawn[i].GetComponent<Animator>().Play("TargetSpawn");
                objsToSpawn[i].SetActive(true);
            }
            yield return new WaitForSeconds(t);
        }

        yield return null;
    }

https://github.com/med-material/Trail-it/blob/master/Assets/Scripts/Game/GameLevel.cs#L417

For this task I suggest you check out IEnumerators and Unity animations. Hope this helps!

Xav1204 commented 2 years ago

I don't need to change the cooldown, it just that I want to use this variable for the duration of the transition.

bastianilso commented 2 years ago

@Xav1204 Ideally the transition happens after the countdown finishes (like shown in the animation from Trail it above). Is that what you mean? The count down is controlled by GameManager.cs, which emits a signal for every second passed. I'm not sure it is ideal for controlling the transition itself.

image

If you are trying to sync the transition to the countdown, I'm not sure how it would work. I do get the idea - that it would look cool if the "wall is building up" while the player is waiting those 3 seconds. But that's not what the 3 second countdown is for - the countdown is to prepare the player to get ready to play - ideally the wall is already built, so the player can focus on just getting ready. I think it's better to keep a separate duration (a 3 seconds for a transition might be too long, typically we aim to fade for shorter periods, e.g. 500ms or so).

Let me know if I misunderstood what you are trying to do. If I did, please elaborate in text, a bit more in depth what you are trying to do.

Xav1204 commented 2 years ago

ok thanks. I will continue my tests for this transition.