私はUnity3D 5を使用してTrain Simulatorを作っています。カーブしたトラックで電車のワゴンをスムーズに曲げ、まっすぐなトラックで普通に戻したいのですが、どうすればいいですか?Unity3D 5でエルミートスプラインコントローラを使用して列車ワゴンを曲げるには?
私はここで
はコードで、Hermite Spline Controller C#のバージョンを使用しています。
using UnityEngine;
using System.Collections;
public class BendTrain : MonoBehaviour {
public Transform trainwagon2;
public Transform trainwagon3;
public Transform waypoint2;
public Transform waypoint3;
public static bool t2 = false;
public static bool t3 = false;
void OnTriggerEnter (Collider col1)
{
if (col1.tag == "b2") {
t2=true;
}
if (col1.tag == "b3") {
t3=true;
}
}
void Update()
{
if (t2)
trainwagon2.transform.rotation = Quaternion.RotateTowards(trainwagon2.transform.rotation, waypoint2.rotation, 2);
if (t3)
trainwagon3.transform.rotation = Quaternion.RotateTowards(trainwagon2.transform.rotation, waypoint2.rotation, 2);
}
}