Knowledge gained by participating in unity1week

2 minute read

Introduction

I participated in unity 1week for the first time as VTuber.
I would like to write about two findings I gained while developing the game.

Development memories </summary> The theme this time was “Increase”. At first, I mistakenly read it as “shaking.” On the first day, we decided on a general concept and verified the operation of the concept with a cube. On the second day, it turned out that the logic created on the first day would not work, so I recreated it from scratch. On the 3rd and 4th days, I implemented it with a gorigori. I think most of them have investigated how to use UniRx. Since this is my first time using navmesh, I also investigated and implemented collision detection. I’m glad I knew most things when I googled. However, I was careful because the information was out of date. I thought that everything except the UI was completed on the 5th day, so I uploaded it to the unity room and checked it. I had been fasting since this day, so I couldn’t get my head around. I realized that it was good to make it early. On the 6th day, we added UI, added BGM, and adjusted the game balance. I’m good at writing code, but I’m not good at making fine adjustments like this. I’m waiting for the day when AI will measure it well. On the 7th day, I implemented the minimap that I came up with the day before, posted an introductory video on youtube, and wrote this article. </details>

Detects that there is no key input for a certain period of time

“The player goes into weight mode if there is no queue input for a certain period of time.” If you want to do this with UniRx, you can write the following code.

this.UpdateAsObservable()
            .Where(_ => Input.anyKeyDown)
            .Timeout(TimeSpan.FromSeconds(0.5)) //0.If there is no input for 5 seconds
            .OnErrorRetry((Exception e) => animator.SetBool("isWalk", false)) //Turn off animation
            .Subscribe();

Tweet function

I had a function to tweet such as the score of the game, but when I run it in the unity room “Twitter.com refused to connect.” I got the message.

    void Tweet() {
        string esctext = UnityWebRequest.EscapeURL($"Infection rate{attak.value}%\n remaining time{remainingTime}Seconds\n{count}/{number.value}Nyanko became a friend("ФДФ)"");
        string esctag = UnityWebRequest.EscapeURL("unity1week");
        string url = UnityWebRequest.EscapeURL("https://unityroom.com/games/");
        string TweetURL = "https://twitter.com/intent/tweet?text=" + esctext + "&hashtags=" + esctag + "&url=" + url;

        Application.OpenURL(TweetURL);
    }

On my machine, it works on windows and webgl, This Application.OpenURL (TweetURL) doesn’t seem to work with unityroom webgl.

I modified it as follows and it works.

    void Tweet() {
        string esctext = UnityWebRequest.EscapeURL($"Infection rate{attak.value}%\n remaining time{remainingTime}Seconds\n{count}/{number.value}Nyanko became a friend("ФДФ)"");
        string esctag = UnityWebRequest.EscapeURL("unity1week");
        string url = UnityWebRequest.EscapeURL("https://unityroom.com/games/");
        string TweetURL = "https://twitter.com/intent/tweet?text=" + esctext + "&hashtags=" + esctag + "&url=" + url;

#if UNITY_WEBGL && !UNITY_EDITOR
        Application.ExternalEval(string.Format("window.open('{0}','_blank')", TweetURL));
#elif UNITY_EDITOR
        System.Diagnostics.Process.Start(TweetURL);
#else
        Application.OpenURL(TweetURL);
#endif
    }

in conclusion

This time, my goal was to “complete my concept within the deadline.” So it was a pretty rough game, but I was able to complete it safely (maybe there are bugs). I had a feeling that I wanted to do this here, but that part did not affect the concept, and I thought about the time and eliminated it.

When I didn’t understand, I borrowed the knowledge of my predecessor by google. I hope this article will be helpful to the people who follow.

Also, UniRx is really good.