//tips
//キャラクター同期対応
Minimap表示の際に同じキャラクター同士で行うと時々自身のminimapカメラではないものが表示される。
photonviewismineで選別できないかと考えたが、rawimageを共有してしまっていることが問題なように思われるので、photonviewismineでない時にはminimapcameraのtargettextureの中身を外すせないか考える。
下記スクリプトをdeerのminimapcameraに組み込む。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class cameratarget : MonoBehaviourPunCallbacks
{
void Start()
{
if (!photonView.IsMine)
{
Camera camera = GetComponent<Camera>();
camera.targetTexture = null;
}
}
}
きちんと機能した。他のキャクターにも共有した。
Wolf役の下記のlayerchangeがうまく機能しておらず、minimapに表示されてしまうので要因を確認する。
DeerActionlistスクリプトのchangeLayer = myPlayer.GetComponentInChildren<ChangeLayer>();が問題になってそうなのでDebug.Log(changeLayer);で確認。
そうするとDeer本体のレイヤーが変更されていることがわかった。本体にもChangeLayerスクリプトが付いていたのでそちらを削除。これで無事に機能するようになった。
Human役の場合のUIボタンを時間によりアンロックされていくような仕様も追加する。deerのhumanUIに新たなスクリプトを追加し、予めskill2,3,4のbuttonのinteractableチェックを外しておく。
下記を作成。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class HumanUITimer : MonoBehaviour
{
float seconds;
[SerializeField]
GameObject skill2;
[SerializeField]
GameObject skill3;
[SerializeField]
GameObject skill4;
void Start()
{
seconds = 0f;
}
void Update()
{
seconds += Time.deltaTime;
if (seconds >= 20f)
{
Button btn = skill2.GetComponent<Button>();
btn.interactable = true;
}
if (seconds >= 30f)
{
Button btn = skill3.GetComponent<Button>();
btn.interactable = true;
}
if (seconds >= 40f)
{
Button btn = skill4.GetComponent<Button>();
btn.interactable = true;
}
}
}
きちんと機能した。他のキャラクターのhumanUIにも同じ処理を行う。
また、一部のボタンに一度しか使えない設定も加える。
Deerのボタンを参考に考える。下記をクリックしたボタンに実行させるメソッドとして考える。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ButtonOneshot : MonoBehaviour
{
public void Oneshot()
{
Button btn = GetComponent<Button>();
btn.interactable = false;
}
}
先のhuman役の場合の非表示と設定が被ってしまい、うまく反映できなかったのでupdateで実行されるタイマーでのボタン表示をboolを用いて一回にした。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class HumanUITimer : MonoBehaviour
{
float seconds;
[SerializeField]
GameObject skill2;
[SerializeField]
GameObject skill3;
[SerializeField]
GameObject skill4;
bool isCalledOnce= false;
bool isCalledOnce3 = false;
bool isCalledOnce4 = false;
void Start()
{
seconds = 0f;
}
void Update()
{
seconds += Time.deltaTime;
if (seconds >= 12f)
{
if (!isCalledOnce)
{
isCalledOnce = true;
Debug.Log("12f");
Button btn = skill2.GetComponent<Button>();
btn.interactable = true;
}
}
if (seconds >= 36f)
{
if (!isCalledOnce3)
{
isCalledOnce3 = true;
Button btn = skill3.GetComponent<Button>();
btn.interactable = true;
}
}
if (seconds >= 60f)
{
if (!isCalledOnce4)
{
isCalledOnce4 = true;
Button btn = skill4.GetComponent<Button>();
btn.interactable = true;
}
}
}
}
これでhuman役でかつ一回しかボタンを使わせたくない場合のinteractive操作が円滑にできるようになった。
各キャラクターの必要なボタンに上記スクリプトをアタッチして行ったが、ダブルタップで実行するfoxのテレポートの使い方を工夫しなければいけないことに気がついた。
if (warpcount > 1)で実行できるワープの回数を制限した。
if (warpcount > 1 && warpcount < 3)
{
transform.position = setwarp.cube_pos;
}
}