My portfolio

Menu▼

  • Top
  • About
  • Portfolio
  • Diary
  • Privacy policy
  • JewerlyHunter

    Play(スマホ非対応)

    Outline

    職業訓練の課題で作成したものを元に1ステージ分作成しました。これが初Unityとなります。

    ミスした時にニコニコ動画風に煽ってくるようにしました。思いつく悪口を書きまくりました。

    DownLoad

    Code (C#)
    ニコニコ動画風のコメントを作成するスクリプトです

    Script public class ResistCommentary : MonoBehaviour { public GameObject commentCanvas; public GameObject uplimit,downlimit; public GameObject maincamera; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } public void RegistComment(string buf,int n=1,bool hiright=false) { System.Random random = new System.Random(); for (int i = 0; i < n; i++) { float rnd = (float)random.NextDouble(); Vector2 commentaryPosition = ((uplimit.transform.position - downlimit.transform.position) * rnd) + downlimit.transform.position; commentaryPosition = commentaryPosition + new Vector2(random.Next(3,30),0); GameObject comment = GameObject.Instantiate(commentCanvas, commentaryPosition, Quaternion.identity); comment.GetComponent<Rigidbody2D>().velocity = new Vector2(random.Next(3,5)*-1, 0); comment.transform.SetParent(maincamera.transform); comment.transform.GetChild(0).GetComponent<TextMeshProUGUI>().text = buf; if(hiright) { comment.transform.GetChild(0).GetComponent<TextMeshProUGUI>().color = Color.red; } } } }