標題幾乎總結了它。我的敵人預製裝置只能在Y軸上實例化,但硬幣預製裝置正在被實例化,即使它們具有相同的座標也是如何。預製沒有在給定的位置實例化
import System.Collections.Generic;
var enemyPrefab : GameObject;
var coinPrefab : GameObject;
public var Coinnumber = 1;
public var Coinnumberside : float = 0.0f;
function OnTriggerEnter(other: Collider)
{
if (other.tag == "Trigger")
{
var StagePosition : Vector3;
StagePosition.z = 5.69 + Coinnumber;
StagePosition.x = 0.0 + Coinnumberside;
StagePosition.y = 0.4;
Instantiate(coinPrefab, StagePosition, Quaternion.identity);
Coinnumber = Coinnumber + Random.Range(5,10);
Coinnumberside = Coinnumberside + Random.Range(0.2,-0.4);
var EnemyPosition : Vector3;
EnemyPosition.z = 5.69 + Coinnumber;
EnemyPosition.x = 0.0 + Coinnumberside;
EnemyPosition.y = 0.4;
Instantiate(enemyPrefab, EnemyPosition, Quaternion.identity);
Coinnumber = Coinnumber + Random.Range(5,10);
Coinnumberside = Coinnumberside + Random.Range(0.2,-0.4);
}
}
你的問題有問題......他們沒有相同的座標。 x和z軸依賴於在兩個賦值之間改變的變量,這是偶然的。也許Coinnumber和Coinnumberside只能在函數結束時更改? –
除了別人已經指出,你怎麼反對樞紐點,全球和本地。他們是否在正確的目標點和方向? – VicM