質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Unity3D

Unity3Dは、ゲームや対話式の3Dアプリケーション、トレーニングシュミレーション、そして医学的・建築学的な技術を可視化する、商業用の開発プラットフォームです。

Q&A

解決済

1回答

1667閲覧

球が接触時、波紋を発生させたい

kudo201810

総合スコア30

Unity3D

Unity3Dは、ゲームや対話式の3Dアプリケーション、トレーニングシュミレーション、そして医学的・建築学的な技術を可視化する、商業用の開発プラットフォームです。

0グッド

0クリップ

投稿2020/07/15 01:53

以下のサンプルシーンを開いて球を落下させたところに、波紋を発生させたいのですが
うまくいきませんでした。

以下のサイトで公開されています。
確認したバージョン:Unity 2019.2.11f1 (64-bit)

Unity 2017.1 の機能の CustomRenderTexture を使ってみた
http://tips.hecomi.com/entry/2017/05/17/020037

Water Simulation using CustomRenderTexture from Unity 2017.1

https://www.youtube.com/watch?time_continue=5&v=jclxfdS3a3w&feature=emb_logo

https://github.com/hecomi/UnityWaterSurface

WaterSimulationというシーンファイルを起動

球をつくって、リジッドボディをつけ、自然落下させています。(コライダーは無効にしました)
球(Sphare)には以下のスクリプトをつけています。

using System.Collections; using System.Collections.Generic; using UnityEngine; public class Sphere_src : MonoBehaviour { public float Ray_distance = 1.0f;//Rayの飛ばせる距離 [SerializeField] CustomRenderTexture texture; [SerializeField] int iterationPerFrame = 5; void Start() { texture.Initialize(); } void Update() { texture.ClearUpdateZones(); UpdateZones(); texture.Update(iterationPerFrame); } void UpdateZones() { RaycastHit hit; RaycastHit hit1; Ray ray1 = new Ray(transform.position, -transform.up);//下へレイを出す if (Physics.Raycast(ray1, out hit1, Ray_distance)) { Debug.Log("hit x:"); Debug.Log(hit1.textureCoord.x); Debug.Log("hit y:"); Debug.Log(hit1.textureCoord.y); Vector2 pos = new Vector2(hit1.textureCoord.x, hit1.textureCoord.y); var ray = Camera.main.ScreenPointToRay(pos); if (Physics.Raycast(ray, out hit)) { Debug.Log("hit!!"); var defaultZone = new CustomRenderTextureUpdateZone(); defaultZone.needSwap = true; defaultZone.passIndex = 0; defaultZone.rotation = 0f; defaultZone.updateZoneCenter = new Vector2(0.5f, 0.5f); defaultZone.updateZoneSize = new Vector2(1f, 1f); var clickZone = new CustomRenderTextureUpdateZone(); clickZone.needSwap = true; clickZone.passIndex = 1; clickZone.rotation = 0f; clickZone.updateZoneCenter = new Vector2(hit.textureCoord.x, 1f - hit.textureCoord.y); clickZone.updateZoneSize = new Vector2(0.01f, 0.01f); texture.SetUpdateZones(new CustomRenderTextureUpdateZone[] { defaultZone, clickZone }); } } } }

ヒットしてることは、デバッグで表示されているので間違いないのですが
波紋が広がりませんでした。

なにが問題なのかが、サイトを読んでも
よく理解できませんでした。
よろしくお願いいたします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

WaterSimulation.csの

void Update()
{
/*
texture.ClearUpdateZones();
UpdateZones();
texture.Update(iterationPerFrame);
*/
}

とコメントアウトしたら動きました。
複数更新するスクリプトがあると動かないようでした。

投稿2020/07/15 04:37

kudo201810

総合スコア30

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問