前提・実現したいこと
現在、対象のオブジェクトを指定した座標を移動させるといったスクリプトを書いています。
目的としては、現実場面のボールの動きを測定し、その動きをUnity上で表現することです.
スクリプトは、座標を一つ一つ手入力し、for文を使用して順番にその座標に移動させれば可能かと考えて作成いたしました。
下記に示してある座標は動作確認のために暫定的に入力したものです。
発生している問題・エラーメッセージ
上述したようにスクリプトを作成したところ、座標を一つ一つ通過するといった感じではなく、最終的に指定している座標付近へ
瞬間移動をしてしまうといった問題が生じています。
該当のソースコード
using System.Collections; using System.Collections.Generic; using UnityEngine; public class move_test : MonoBehaviour { public Vector3 [] pos; Vector3 pos1 = new Vector3(-11f, 0.15f, 1f); Vector3 pos2 = new Vector3(-12f, 0.15f, 1f); Vector3 pos3 = new Vector3(-11.5f, 0.15f, 1f); Vector3 pos4 = new Vector3(-11f, 0.15f, 1f); Vector3 pos5 = new Vector3(-10.5f, 0.15f, 1f); Vector3 pos6 = new Vector3(-10f, 0.16f, 1f); Vector3 pos7 = new Vector3(-9.5f, 0.16f, 1f); Vector3 pos8 = new Vector3(-9f, 0.16f, 1f); Vector3 pos9 = new Vector3(-8.5f, 0.17f, 1f); Vector3 pos10 = new Vector3(-8f, 0.17f, 1f); Vector3 pos11 = new Vector3(-7.5f, 0.17f, 1f); Vector3 pos12 = new Vector3(-7f, 0.17f, 1f); Vector3 pos13 = new Vector3(-6.5f, 0.18f, 1f); Vector3 pos14 = new Vector3(-6f, 0.18f, 1f); Vector3 pos15 = new Vector3(-5.5f, 0.18f, 1f); Vector3 pos16 = new Vector3(-5f, 0.19f, 1f); Vector3 pos17 = new Vector3(-4.5f, 0.19f, 1f); Vector3 pos18 = new Vector3(-4f, 0.19f, 1f); Vector3 pos19 = new Vector3(-3.5f, 0.19f, 1f); Vector3 pos20 = new Vector3(-3f, 0.19f, 1f); Vector3 pos21 = new Vector3(-2.5f, 0.2f, 1f); Vector3 pos22 = new Vector3(-2f, 0.2f, 1f); Vector3 pos23 = new Vector3(-1.5f, 0.2f, 1f); Vector3 pos24 = new Vector3(-1f, 0.2f, 1f); Vector3 pos25 = new Vector3(-0.5f, 0.19f, 1f); Vector3 pos26 = new Vector3(0f, 0.19f, 1f); Vector3 pos27 = new Vector3(0.5f, 0.18f, 1f); Vector3 pos28 = new Vector3(1f, 0.17f, 1f); Vector3 pos29 = new Vector3(1.5f, 0.17f, 1f); Vector3 pos30 = new Vector3(2f, 0.16f, 1f); // Use this for initialization void Start () { int sum = 0; for (int i = 0; i < 30; i++) ; sum = sum + 1; pos = new Vector3[30]; Vector3 ballpos = pos[sum]; this.gameObject.transform.position = new Vector3(ballpos.x, ballpos.y, ballpos.z); } // Update is called once per frame void Update () { } }
試したこと
補足情報(FW/ツールのバージョンなど)
Unity 2018.2.7.f1

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/09/13 09:48
2018/09/13 10:03
2018/09/13 11:29
2018/09/13 12:04