BTTF
バック・トゥ・ザ・フューチャーでは、今年あたりは車が空を飛んでいました。
飛ばせます。Unityの中なら。
大抵の車モデルにはタイヤにTransformが付いていると思うので、
こんな感じで飛ばせるんじゃないかと思います。
TimeMachiene.cs
using UnityEngine;
using System.Collections;
public class TimeMachiene : MonoBehaviour {
public Transform m_FrontL;
public Transform m_FrontR;
public Transform m_BackL;
public Transform m_BackR;
public float m_TransOfsY;
public Camera m_Camera;
private GameObject m_pivotL;
private GameObject m_pivotR;
private Quaternion m_pivotLToRot;
private Quaternion m_pivotRToRot;
private float m_rate=0.01f;
private Vector3 m_toPos;
private Quaternion m_toRot;
private bool m_CamMove;
// Use this for initialization
void Start () {
m_pivotL = new GameObject("pivotL");
m_pivotL.transform.SetParent(m_FrontL.transform.parent);
m_pivotL.transform.localPosition = m_FrontL.transform.localPosition - Vector3.left * m_TransOfsY;
m_FrontL.transform.SetParent(m_pivotL.transform);
m_BackL.transform.SetParent(m_pivotL.transform);
m_pivotLToRot = m_pivotL.transform.localRotation * Quaternion.FromToRotation (Vector3.left, Vector3.down);
m_pivotR = new GameObject("pivotR");
m_pivotR.transform.SetParent(m_FrontR.transform.parent);
m_pivotR.transform.position = m_FrontR.transform.position + Vector3.left * m_TransOfsY;
m_FrontR.transform.SetParent(m_pivotR.transform);
m_BackR.transform.SetParent(m_pivotR.transform);
m_pivotRToRot = m_pivotR.transform.localRotation * Quaternion.FromToRotation (Vector3.left, Vector3.up);
m_toPos = gameObject.transform.position;
m_toRot = gameObject.transform.rotation;
StartCoroutine (animCo ());
}
// Update is called once per frame
void Update () {
m_pivotL.transform.localRotation = Quaternion.Lerp (m_pivotL.transform.localRotation, m_pivotLToRot, m_rate);
m_pivotR.transform.localRotation = Quaternion.Lerp (m_pivotR.transform.localRotation, m_pivotRToRot, m_rate);
Quaternion camRot = Quaternion.LookRotation (gameObject.transform.position-m_Camera.transform.position);
gameObject.transform.position = Vector3.Lerp (gameObject.transform.position, m_toPos, m_rate);
gameObject.transform.rotation = Quaternion.Lerp (gameObject.transform.rotation, m_toRot, m_rate);
if (m_CamMove) {
m_Camera.transform.rotation = Quaternion.Lerp(m_Camera.transform.rotation,camRot,m_rate);
}
}
private IEnumerator animCo(){
m_rate = 0.01f;
yield return new WaitForSeconds (1f);
m_toPos += Vector3.up * 0.2f;
yield return new WaitForSeconds (2f);
m_rate = 0.005f;
m_CamMove = true;
m_toPos += Vector3.up * 1.0f;
m_toPos -= gameObject.transform.forward * 0.5f;
m_toRot *= Quaternion.AngleAxis(30f, Vector3.forward);
yield return new WaitForSeconds (3f);
m_rate = 0.1f;
m_toPos += gameObject.transform.forward * 5f;
m_toRot *= Quaternion.AngleAxis(30f, Vector3.up);
}
}
サンプルでは無料アセットを使用しました。
https://www.assetstore.unity3d.com/jp/#!/content/19264
Author And Source
この問題について(BTTF), 我々は、より多くの情報をここで見つけました https://qiita.com/ELIXIR/items/c98bedaf1acd95cf7ff9著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .