Unity 求两 Vector3 的中间坐标

Unity 求两 Vector3 的中间坐标_第1张图片 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BetweenPoint : MonoBehaviour {

    public Transform pos1;
    public Transform pos2;
    public Transform betPre;
    // Use this for initialization
    Vector3 betweenPos;
	// Update is called once per frame
	void Update () {
        betweenPos = (pos1.position + pos2.position) / 2;
        betPre.position = betweenPos;
    }
}

测试结果:

Unity 求两 Vector3 的中间坐标_第2张图片

你可能感兴趣的:(unity)