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

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

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

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

Q&A

1回答

509閲覧

Unityでの的あて 当たり判定

退会済みユーザー

退会済みユーザー

総合スコア0

Unity

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

0グッド

0クリップ

投稿2021/05/15 07:59

編集2021/05/15 08:02

Unityでの的あてを作っていてボールが的に当たったらスコアに点数を1つずつ上げていくものを作っています。ボールを発射するといきなり16というスコアが出てしまいます。おそらく発射するときのブロックとボールが当たっているのでそこが原因だと思うのですが解決策が分かりません。ブロックのbox colliderコンポーネントのチェックなどを外したのですが変わりませんでした。教えてくださいお願いします!

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

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

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

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

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

guest

回答1

0

関連するScriptを見てみない限りは分からないので見せてもうらうことは可能ですか?

投稿2021/05/15 10:26

YDK

総合スコア63

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

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

退会済みユーザー

退会済みユーザー

2021/05/15 13:07

ScnManagerのscript using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class ScnManager : MonoBehaviour { GameObject pointText; int point = 0; public float totalTime = 30.0f; //制限時間(秒) GameObject timerGauge; float timerX = 30.0f; bool timerFinish = false; // Start is called before the first frame update void Start() { pointText = GameObject.Find("Point"); timerGauge = GameObject.Find("timerGauge"); } // Update is called once per frame void Update() { pointText.GetComponent<Text>().text = point.ToString("D3"); timerX -= Time.deltaTime; float gauge = timerX / totalTime; timerGauge.GetComponent<Image>().fillAmount = gauge; if (timerX <= 0.0f) { timerFinish = true; } } public void GetPoint() { //終了していない場合は if (timerFinish == false) point++; } } bulletのscriptがこれで using System.Collections; using System.Collections.Generic; using UnityEngine; public class bullet : MonoBehaviour { GameObject scnManager; // Start is called before the first frame update void Start() { scnManager = GameObject.Find("ScnManager"); } // Update is called once per frame void Update() { transform.position += transform.forward * Time.deltaTime * 1; } void OnTriggerEnter(Collider other) { scnManager.GetComponent<ScnManager>().GetPoint (); } } 動かすブロックのscript using System.Collections; using System.Collections.Generic; using UnityEngine; public class BlockController : MonoBehaviour { void Update() { // 左に移動 if (Input.GetKey(KeyCode.LeftArrow)) { this.transform.Translate(-0.05f, 0.0f, 0.0f); } // 右に移動 if (Input.GetKey(KeyCode.RightArrow)) { this.transform.Translate(0.05f, 0.0f, 0.0f); } // 前に移動 if (Input.GetKey(KeyCode.UpArrow)) { this.transform.Translate(0.0f, 0.0f, 0.5f); } // 後ろに移動 if (Input.GetKey(KeyCode.DownArrow)) { this.transform.Translate(0.0f, 0.0f, -0.05f); } } }
fiveHundred

2021/05/15 13:16

> YDKさん ここは回答欄です。 このような「回答が出来ないのでコードや追記をしてほしい」という内容はこの欄ではなく、「質問への追記・修正、ベストアンサー選択の依頼」の欄に投稿してください。 > Fav.さん このようなコードは、基本的にコメントではなく質問に追記してください。 その際は、コード用の書式を使うようにお願いいたします。
退会済みユーザー

退会済みユーザー

2021/05/15 13:28

わかりました
YDK

2021/05/15 13:39

すみません。全然気づかなかったです。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問