玩家和敌人之间有一个与 distance.magnitude 成比例的立方体。我想将这个 Scaling Cube 设置在英雄和敌人之间。那么是否可以使用两个对象之间的幅度作为位置。
这是我的脚本:
var hero : Transform;
var enemy : Transform;
var magDistance = 0.0;
var setPosition = 0.0;
function Update () {
var heDistance : Vector3 = (hero.position - enemy.position)/2;
magDistance = heDistance.magnitude;
setPosition = heDistance.magnitude/2;
transform.localScale = Vector3(1,1,magDistance);
}
我使用 heDistance.magnitude/2 来获得距离的中间。非常感谢您的帮助。提前致谢!:)