Help us understand the problem. What is going on with this article?

2点の座標と角度の中間を求める

More than 3 years have passed since last update.

Vector3.Lerp と Quaternion.Lerp が便利

BlendedPosition.cs
using UnityEngine;
using System.Collections;

public class BlendedPosition : MonoBehaviour
{
    [SerializeField] private Transform a;
    [SerializeField] private Transform b;

    void Start ()
    {

    }

    void Update ()
    {
        transform.position = Vector3.Lerp(a.position, b.position, 0.5f);
        transform.rotation = Quaternion.Lerp(a.rotation, b.rotation, 0.5f);
    }
}

追記:2015/11/08

そもそも2点間の中間をもとめるには、補間方法が違う Lerp と Slerp があります。
http://docs.unity3d.com/jp/current/ScriptReference/Vector3.Lerp.html
http://docs.unity3d.com/jp/current/ScriptReference/Vector3.Slerp.html

パフォーマンスと精度に違いあるようですが、試してないので不明です。
http://forum.unity3d.com/threads/what-is-the-difference-of-quaternion-slerp-and-lerp.101179/

補間の違いについては下記コメントの @Ushio@github さんのコードがすごく分かりやすいです。

nenjiru
Creative Technologist https://twitter.com/nenjiru http://www.slideshare.net/minorunakanou
http://nenji.ru
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away