だんしん

画面タップでカメラを切り替える アンドロイド unity

vjっぽく、音に合わせて映像を操作したい、

画面を九つに分割して透明ボタンをつけようと思う

左の三つはカメラ制御にしよう

横、回転、前

中三つ
登場人物のアクション、
小、中、高

右三つ
ライティング、ステージの演出
暗い、普通、派手

って感じを目標に。

カメラ制御

virtualcameraをタイムライン制御で動かそうと思う。

virtualcamela二個置いたらnoiseが利かなくなった。
なぜ

handheld extrime にしたら謎にグルグル動く。

一度けしてvirtualcamera配置しなおしたら治った。

ボタンの大きさの調節の仕方とかを調べる。
[Unity] Button をCanvasに設置する

https://uni.gas.mixh.jp/unity/button.html

このとおりにやったらエラー出た。
ボタンのadcompornentから空のスクリプト追加して
かいたらうまくいった。


【Unity】UIを端末に合わせたサイズに調節する

https://dojican-lab.blogspot.com/2015/08/unity.html

カメラの切り替え、3パターンのアングル、
ボタンクリックのところにカメラ切り替えのスクリプト。
vcamを三つつくって、それをオンオフすればいいと思う。

【Unity】オブジェクトの表示・非表示をSetActiveでする方法【スクリプトあり】
https://miyagame.net/setactive/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class botan1no1 : MonoBehaviour {
   public GameObject itinoiti;
   public GameObject itinoni;
   public GameObject itinosan;

   // Use this for initialization
   void Start () {
		
	}

   public void BTonClick()
   {
       itinoiti.SetActive(true);
       itinoni.SetActive(false);
       itinosan.SetActive(false);
   }
}

これ書くのに40分くらいかかった。
スクリプト嫌い。

似たようなのをボタンにつけていく。

人物の動きanimatorで切り替える

animatorcontroller、大量の人を動かすのめんどそうだ。

【UnityC#講座】AnimatorControllerの使い方
https://unity-shoshinsha.biz/archives/705

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class botan2no1 : MonoBehaviour {

   public GameObject ninoiti;

   Animator animator;
   // Use this for initialization
   void Start()
   {
       animator = ninoiti.GetComponent<Animator>();
   }

   public void BTonClick()
   {
       animator.SetBool("ninoitiosu", true);
       animator.SetBool("ninoniosu", false);
       animator.SetBool("ninosannosu", false);

   }
}

みたいな感じのスクリプト書いた。
animation controller のトランジション、ボタン押したらすぐ反応するようにしたい場合はhas exit timeのチェック外す

派手な背景

背景の切り替え
出現するボールの大きさ

等をいじりたいと思う、


パーティクルとばすために、アセットストアで検索、

Simple Particle Pack使った。

標準のパーティクルアセットで

【Unity】パーティクルで紙ふぶきを散らす
http://tsubakit1.hateblo.jp/entry/2015/09/04/233000

この辺を見ながらnoiseとかのパラメーターをいじる

ボタンでオブジェクトごとオンオフ


ライトの色をランダム変化

スクリプトでライトをコントロールする
http://prince9.hatenablog.com/entry/2018/11/19/184813

intencityとcolorに時間制御でランダムな数値入れる

時間は0.1秒以上2秒以下で。


ライトカラー
https://docs.unity3d.com/ja/current/ScriptReference/Light-color.html

時間の処理

[Unity] 一定の時間間隔で処理を実行する方法まとめ(時間制御)
https://qiita.com/Nagitch/items/fb9157b1cb27f3d37696

Unity ランダムにカラーを生成する。その色をマテリアルに貼り付ける。
https://gist.github.com/hiroyukihonda/8430454


高彩度かつ高明度色をランダムに生成する
http://unity-yuji.xyz/random-high-saturation-brightness/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class lightsousa : MonoBehaviour {

   Color GetRandomVividColor(float alpha)
   {
       Color c;
       float rnd = Random.value;
       if (rnd < 1f / 6f)
       {
           c = new Color(0f, 1f, Random.value, alpha);
       }
       else if (rnd < 2f / 6f)
       {
           c = new Color(0f, Random.value, 1f, alpha);
       }
       else if (rnd < 3f / 6f)
       {
           c = new Color(1f, 0f, Random.value, alpha);
       }
       else if (rnd < 4f / 6f)
       {
           c = new Color(Random.value, 0f, 1f, alpha);
       }
       else if (rnd < 5f / 6f)
       {
           c = new Color(1f, Random.value, 0f, alpha);
       }
       else
       {
           c = new Color(Random.value, 1f, 0f, alpha);
       }
       return c;
   }

   public float duration = 1.0F;
   public Color color0 = Color.red;
   public Color color1 = Color.blue;
   public GameObject slight;
   public Light lt;

   //制限時間とカウンター
   public float timeOut;
   private float timeElapsed;

   void Start()
   {
       //制限時間にランダムな数字
       timeOut = Random.Range(0.1f, 2f);

       //色切り替え時間にもランダムな数字

       lt = slight.GetComponent<Light>();
       duration = Random.Range(0.1f, 2f);

   }
   void Update()
   {
       float t = Mathf.PingPong(Time.time, duration) / duration;
       lt.color = Color.Lerp(color0, color1, t);


       //制限時間に到達するまでにやる処理
       timeElapsed += Time.deltaTime;

       if (timeElapsed >= timeOut)
       {
           // Do anything
           //色と時間を入れなおす

           color0 = GetRandomVividColor(1.0f);
           color1 = GetRandomVividColor(1.0f);

           timeOut = Random.Range(0.1f, 2f);
           duration = Random.Range(0.1f, 2f);

           timeElapsed = 0.0f;
       }

   }
}

とりあえずやりたい感じのことができてよかった。

画面がまだ地味な気がするので、処理が軽くて派手な演出を考えたいところ。



この記事が気に入ったらサポートをしてみませんか?