code VR

Unity×VR(174)

スポンサーリンク

//tips

//微調整

シーンプレイヤーの生成エラーはキャラクター選択画面のクリック時間を要因にして発生しているのではないかと考え、キャラクター選択をクリックする時間を変更してみたが特に問題はなかった。

プレイヤーを動かしていて気になったことは、ダメージ判定がやはり特殊で距離とタイミングが非常に重要になっている。

もう少し容易にダメージを与えられないかの検討を加える。

また、ダメージを受けて消滅した後のプレイヤーカメラ視点が上空のものとなってしまうので、wolf役のカメラ視点に切り替わるようにする。

ダメージ判定複雑になっているのでもっとシンプルにできないか見直していく。

現在は攻撃側のプレイヤーのEnvPlaymove5photonスクリプトにて、下記のようにボタンを押されたら攻撃用のコライダーを0.2秒オンにするところから始まっている。

public void Attackmotion()
{
animator.SetTrigger("Attack1");
StartCoroutine("WaitAnimationfin");
}

IEnumerator WaitAnimationfin()
{
photonView.RPC(nameof(AttackColliderDamage), RpcTarget.All);

yield return new WaitForSeconds(0.2f);

photonView.RPC(nameof(AttackColliderDamage), RpcTarget.All);
}

[PunRPC]
void AttackColliderDamage()
{
SphereCollider rightfootcollider = rightfoot.GetComponent<SphereCollider>();

if(rightfootcollider.enabled == false)
{
rightfootcollider.enabled = true;
}
else
{
rightfootcollider.enabled = false;
}

}

このコライダーとの接触をダメージを受ける側のHPScript2で取得することになる。

HPScript2では、OnTriggerEnter(Collider other)以下でその反応をとっており、Debuffcheckの後に攻撃側のオンになった"Weapon”タグ付きのコライダーを検知し、roleや強化攻撃となっていないかの確認を経て、photonにてダメージ計算の適用とクールタイムの実行を行なっている。

0.2秒が短すぎてother.gameObject.tagが取られる前にオフになり、ダメージ判定が行われなくなっていないか確認。攻撃を受けた側にDebug.Log("human”);が表示されているかの確認を行う。

private void OnTriggerEnter(Collider other)
{
if (photonView.IsMine)
{
charaModeManager = other.GetComponent<CharaModeManager>();
GameObject rootobj = other.transform.root.gameObject;
envPlaymove5photon = rootobj.GetComponent<EnvPlaymove5photon>();

MoveEnemy = rootobj.GetComponent<MoveEnemy>();

if (envPlaymove5photon == null&& MoveEnemy == null)
{
return;
}

if (MoveEnemy == null)//else
{
if (envPlaymove5photon.rabitslowflag)
{
Debuffcheck();

envPlaymove5photon.Rabitslowflag();
}

if (envPlaymove5photon.foxdarkflag)
{
Debuffcheck2();

envPlaymove5photon.Foxdarkflag();
}

if (envPlaymove5photon.moosehealflag)
{
powerRecoverall();

envPlaymove5photon.Moosehealflag();//これでoffにする
}

if (envPlaymove5photon.moosestopflag)
{
Debuffcheck3();

envPlaymove5photon.Moosestopflag();
}

}

if (other.gameObject.tag == "Weapon" && DuringAttack == false)//playerの攻撃オブジェクトタブ
{

DuringAttack = true;

Debug.Log("charaModeManager.wolfmode"+ charaModeManager.wolfmode);

if (charaModeManager.wolfmode)
{

if (charaModeManager.ultimateflag)
{
photonView.RPC(nameof(AttackDamage100), RpcTarget.All);
//hPScript.hp -= powerEnemy * 100;
charaModeManager.Ultimateturnon();
Debug.Log("ultimateultimate");

}
else
{
photonView.RPC(nameof(AttackDamage2), RpcTarget.All);
//hPScript.hp -= powerEnemy * 2;
Debug.Log("wolfmode");

}

}
else
{
if (!charaModeManager.deerpowerflag)
{
photonView.RPC(nameof(AttackDamage), RpcTarget.All);
//hPScript.hp -= powerEnemy;
Debug.Log("human");
}
else
{
photonView.RPC(nameof(AttackDamage2), RpcTarget.All);
//hPScript.hp -= powerEnemy * 2;
Debug.Log("human");
charaModeManager.Deerpowerturnon();
}

}

if (hp <= 0)
{
Debug.Log(gameObject.name);

if (gameObject.name == "Polygonal Golem Orange (1)(Clone)")
{
Debug.Log("GohlemSoul");

Golemfollow Golemfollow = GameObject.Find("GolemOrangefollow(Clone)").GetComponent<Golemfollow>();
Golemfollow.Dropgolemitem();
}

if (gameObject.name == "Polygonal Golem Orange (2b) (Clone)")
{
Debug.Log("GohlemSoul");

Golemfollow Golemfollow = GameObject.Find("GolemOrangefollow2(Clone)").GetComponent<Golemfollow>();
Golemfollow.Dropgolemitem();
}

if (gameObject.name == "Polygonal Golem Orange (3c) (Clone)")
{
Debug.Log("GohlemSoul");

Golemfollow Golemfollow = GameObject.Find("GolemOrangefollow3(Clone)").GetComponent<Golemfollow>();
Golemfollow.Dropgolemitem();
}

photonView.RPC(nameof(DestroyObj), RpcTarget.All);
//Destroy(this.gameObject); //ゲームオブジェクトが破壊される

}
}
}
}

さらにクールタイムを下記のように1秒間設けているが体感ではかなりの時間に感じられるのでこちらをもう少し短くして問題が大きないかを確認してみる。0.5秒へ短縮。

[PunRPC]
void AttackDamage()
{
hp -= 1;
Debug.Log("AttackDamage");

StartCoroutine("CooltimeAnimation");
}

IEnumerator CooltimeAnimation()
{
yield return new WaitForSeconds(1f);
DuringAttack = false;
}

動作確認したところHPScript2の接触オブジェクトデバッグDebug.Log("other.gameObject" + other.gameObject);に地下-5の位置にあるsphereのコライダーを取得してしまっていることがわかった。これが攻撃判定が入ったり、入らなかったりする要因となっている。

Minimapsphereはminimapに位置を表示させるためだけに設定しているのでコライダーのアタッチを外して様子を見てみる。

問題なくダメージ判定が出るようになった。ただ、判定領域は若干狭いよう。

検出コライダーはプレイヤーの攻撃コライダーのみとすることができた。

 

人気の記事

1

皆さん、ついに、エアラインでも、サブスクリプションが始まったのはご存じですか? まだ実験段階ですが、ANAが、定額全国住み放題サービスを提供する「ADDress」と組んで、国内線を4回まで定額利用可能 ...

2

無料でネットショップを開けるアプリとして多くの人に驚きを与えたBASE株式会社が、2019年10月25日東証マザーズに上場しました。2020年2月時点で90万店を超えるショップを抱えるまでに成長してい ...

3

2011年にサービスを開始してから圧倒的な成長率を誇るインテリア通販サイト 【FLYMEe/フライミー】を皆さんご存じでしょうか。 「自分のイメージするインテリア、本当に欲しいインテリアがどこにあるの ...

4

ついに、noteの月間アクティブユーザー数が4400万人(2020年3月時点)に到達しました。 そもそも、「note」とは、クリエイターが、文章やマンガ、写真、音声を投稿することができ、ユーザーはその ...

5

ボードゲームカフェが1日2回転で儲かるという記事をみつけたので興味を持ち、調べてみました。 まずは、需要がどれくらいあるのか、市場のようすからみていきましょう。 世界最大のボードゲーム市場はドイツで、 ...

-code, VR
-,

Copyright© BUSINESS HUNTER , 2023 All Rights Reserved Powered by AFFINGER5.