Celeste the WereCat (Text Adventure Game)

I added some extra fluff. Getting the particle fields to work as I wanted and to be able to turn them off and on as needed took some time, but what really drove me nuts was getting the sound effects to work correctly. Literally took me two days of trying different methods, the key was tying the sound effect trigger to the key press.

I also added a second box, one for text story and one for story choices in both the scriptable object and the main script, it saved a lot of time with formatting and I think made it look a bit nicer. (There is a 3rd box for “trigger key words” that turn the particle feilds on or off as needed but that’s all behind the scenes)

The story itself was expressly written for my six year old daughter, she loves the story and the game, I don’t expect a lot of other people too. But I’m sharing it anyways :slight_smile: If anyone has feedback I’ll take it, if you have a six year old they might enjoy the game more than you :stuck_out_tongue:

Edit: All SFX are royalty free/licensed for any use. I’m obviously not going to make any money off this game, but just wanted to clarify that.

1 Like

Congrats on your game! :partying_face:

1 Like

Yo! This is sick! I was also trying to add in sound into my game and I came up with a different solution than you did.

I added a serialized field with just a string and created a sound script that would pull from that field whenever there was a new state called. I’m still having some issues with it but I hadn’t thought of tying in the new sound to a new button press.

I would be very interested in looking at your code if there’s a way you could share that. I’m curious how you got the right sound to play on the right state.

This is really really good btw! :slight_smile:

1 Like

Thanks so much! That really made my night :smiley:

Here are the code snippets I used to get the SFX to work properly. Hopefully you will find them helpful.

So this is in the StoryUpdate() method just like the tutorial:

    var updateStory = state.UpdateStory();
    for (int index = 0; index < updateStory.Length; index++)
    {
        if(Input.GetKeyDown(KeyCode.Alpha1 + index) || Input.GetKeyDown(KeyCode.Keypad1 + index))
        {
            state = updateStory[index];
            PlayTheSFX();
        }
    }

And here is the PlayTheSFX method:

private void PlayTheSFX()
{
    if(player.isPlaying)
    {
        player.Stop();
    }

    sfxClips = state.GetSFX();

    if(sfxClips.Length == 0)
    {
        //do nothing
    }
    else if(sfxClips.Length == 1)
    {
        player.clip = sfxClips[0];
        player.Play();
    }
    else if(sfxClips.Length > 1)
    {
        StartCoroutine(PlayMultiple());         
    }
}

(Sloppy code I know, but I’ve still got a lot to learn and I was just happy to get something working outside of what was being shown in the tutorial.)

In the state file, strictly in regard to the audio I added an array for audio clips that I could attatch to each state:

[SerializeField] AudioClip sfx;

And a return method:

public AudioClip[] GetSFX()
{
    return sfx;
}

It all makes sense in my head, but if it isn’t clear what I did just shoot me a message and I’d be happy to send you over the two .cs files so you can look at them in full context.

Oh, and the code snippet for the coroutine, I don’t fully understand why it was necessary other than the “yeild waitforseconds” will apparently only work in an IEnumerator… which I honestly have no idea what that is. I just poked around on the internet and fiddled until I got to work :rofl:

private IEnumerator PlayMultiple()
{
    foreach(AudioClip x in sfxClips)
    {
        player.clip = x;
        player.Play();
        yield return new WaitForSeconds(x.length);
    }

}

Yes! Ty!

I came up with something similar but mine has more steps and pulls from 3 different files and it doesn’t actually work that well… so maybe it’s not similar hahaha.

I was also having issues with my sound not fully playing on wake and I also messed with Coroutines but hahah I couldn’t get it to work.

if you could send over the two cs files that would be amazing! I want to dig into it and see how all of it works.

Be happy too. I uploaded just the cs files to github and a few screenshots for reference. I included all the cs files, as for audio the ones of interest are - TheWereCatGame.cs - State.cs - TheRain.cs and the 3 PNG’s

You don’t have to have a github account to view them, you might if you want to download them but I’m not 100% sure about that.

This was SO SO Helpful! I looked through and I figured out that I wasn’t declaring any audiosource in the beginning which is why I was having so much trouble with my code. I’m like a complete beginner to any coding so looking through your lines was really helpful.

Also, I don’t think it was messy at all! I found it very easy to follow especially with all the comments :slight_smile: . I basically just copied your code into mine changing around a few function names and such I hope you don’t mind.

Thanks again for all your help! Your killing it!

1 Like

Appreciate your kind words :slight_smile:

Good luck with finishing up your text adventure game, message me when you upload it, I’d love to check it out.

And don’t worry about copying the code and changing the names for your purposes, it’s very common and perfectly acceptable, a solid quarter of all the code I’ve ever written has been copied from stackoverflow :stuck_out_tongue:

1 Like

I love that you made it for your daughter! The sounds really kept me engaged in the story and I won! Yay! Thank you for sharing your game it was very enjoyable good job!

1 Like

Thanks so much! I’m glad you enjoyed it :smiley: