【3Dゲームエンジン】Unity質問スレッド31at GAMEDEV【3Dゲームエンジン】Unity質問スレッド31 - 暇つぶし2ch■コピペモード□スレを通常表示□オプションモード□このスレッドのURL■項目テキスト679:名前は開発中のものです。 17/10/08 09:26:32.81 s4UEAkq4.net https://docs.unity3d.com/jp/540/ScriptReference/Transform-parent.html これで設定すればいいんじゃない 680:名前は開発中のものです。 17/10/08 13:02:56.37 fTBqzW3p.net >>658 こんな感じか? public class RotationFollower : MonoBehaviour { public Transform target; private Quaternion prev; void Start () { if (target != null) { prev = target.rotation; } } void Update () { if (target != null) { var rot = target.rotation * Quaternion.Inverse (prev); transform.rotation = rot*transform.rotation; prev = target.rotation; } } } 重要なのはQuaternionの掛け算は、前後関係入れ替えると回転の適用順が逆になり、結果が違うということ。 まずワールド座標系でAの回転量だけ回す、次に回転後の座標系でBの回転を適用する必要がある。 transform.rotation = rot*transform.rotation; ↑この行を transform.rotation *= rot; に変えて挙動を比較してみると結果の違いが観測できるだろう。 次ページ最新レス表示レスジャンプ類似スレ一覧スレッドの検索話題のニュースおまかせリストオプションしおりを挟むスレッドに書込スレッドの一覧暇つぶし2ch