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

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

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

C#はマルチパラダイムプログラミング言語の1つで、命令形・宣言型・関数型・ジェネリック型・コンポーネント指向・オブジェクティブ指向のプログラミング開発すべてに対応しています。

Unity3D

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

Q&A

1回答

217閲覧

Unityでオブジェクトの移動

bbbd

総合スコア13

C#

C#はマルチパラダイムプログラミング言語の1つで、命令形・宣言型・関数型・ジェネリック型・コンポーネント指向・オブジェクティブ指向のプログラミング開発すべてに対応しています。

Unity3D

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

1グッド

0クリップ

投稿2019/02/16 07:06

下記スクリプトで操作しているオブジェクトを指定座標(x1,y1,z1),(x2,y2,z2),(x3,y3,z3)などを通るようにさせるにはどのようにスクリプトをアレンジすればよいでしょうか?
現在,オブジェクトは直進しています.
ある程度直進後,カーブを描くようにオブジェクトを移動させたいです.
Unityのアニメーション機能を使ってみましたが,思うような挙動になりませんでした.

よろしくお願い致します.

using

1using UnityEngine; 2 3namespace UnityStandardAssets.Vehicles.Aeroplane 4{ 5 [RequireComponent(typeof (Rigidbody))] 6 public class AeroplaneController : MonoBehaviour 7 { 8 [SerializeField] private float m_MaxEnginePower = 40f; // The maximum output of the engine. 9 [SerializeField] private float m_Lift = 0.002f; // The amount of lift generated by the aeroplane moving forwards. 10 [SerializeField] private float m_ZeroLiftSpeed = 300; // The speed at which lift is no longer applied. 11 [SerializeField] private float m_RollEffect = 1f; // The strength of effect for roll input. 12 [SerializeField] private float m_PitchEffect = 1f; // The strength of effect for pitch input. 13 [SerializeField] private float m_YawEffect = 0.2f; // The strength of effect for yaw input. 14 [SerializeField] private float m_BankedTurnEffect = 0.5f; // The amount of turn from doing a banked turn. 15 [SerializeField] private float m_AerodynamicEffect = 0.02f; // How much aerodynamics affect the speed of the aeroplane. 16 [SerializeField] private float m_AutoTurnPitch = 0.5f; // How much the aeroplane automatically pitches when in a banked turn. 17 [SerializeField] private float m_AutoRollLevel = 0.2f; // How much the aeroplane tries to level when not rolling. 18 [SerializeField] private float m_AutoPitchLevel = 0.2f; // How much the aeroplane tries to level when not pitching. 19 [SerializeField] private float m_AirBrakesEffect = 3f; // How much the air brakes effect the drag. 20 [SerializeField] private float m_ThrottleChangeSpeed = 0.3f; // The speed with which the throttle changes. 21 [SerializeField] private float m_DragIncreaseFactor = 0.001f; // how much drag should increase with speed. 22 23 public float Altitude { get; private set; } // The aeroplane's height above the ground. 24 public float Throttle { get; private set; } // The amount of throttle being used. 25 public bool AirBrakes { get; private set; } // Whether or not the air brakes are being applied. 26 public float ForwardSpeed { get; private set; } // How fast the aeroplane is traveling in it's forward direction. 27 public float EnginePower { get; private set; } // How much power the engine is being given. 28 public float MaxEnginePower{ get { return m_MaxEnginePower; }} // The maximum output of the engine. 29 public float RollAngle { get; private set; } 30 public float PitchAngle { get; private set; } 31 public float RollInput { get; private set; } 32 public float PitchInput { get; private set; } 33 public float YawInput { get; private set; } 34 public float ThrottleInput { get; private set; } 35 36 private float m_OriginalDrag; // The drag when the scene starts. 37 private float m_OriginalAngularDrag; // The angular drag when the scene starts. 38 private float m_AeroFactor; 39 private bool m_Immobilized = false; // used for making the plane uncontrollable, i.e. if it has been hit or crashed. 40 private float m_BankedTurnAmount; 41 private Rigidbody m_Rigidbody; 42 WheelCollider[] m_WheelColliders; 43 private void Start() 44 { 45 m_Rigidbody = GetComponent<Rigidbody>(); 46 // Store original drag settings, these are modified during flight. 47 m_OriginalDrag = m_Rigidbody.drag; 48 m_OriginalAngularDrag = m_Rigidbody.angularDrag; 49 50 for (int i = 0; i < transform.childCount; i++ ) 51 { 52 foreach (var componentsInChild in transform.GetChild(i).GetComponentsInChildren<WheelCollider>()) 53 { 54 componentsInChild.motorTorque = 0.18f; 55 } 56 } 57 } 58 59コード
bochan2👍を押しています

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

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

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

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

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

guest

回答1

0

質問頂きありがとうございます。

こちらのサイトにやり方(動くコード)が書いてあるので試してみてはいかがでしょうか?

https://catlikecoding.com/unity/tutorials/curves-and-splines/

投稿2019/02/16 08:55

bochan2

総合スコア2050

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

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

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

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問