我有一個腳本調用死亡,其重新滋生的開始位置播放器時的碰撞是真實的。我試圖計算一下,當這次碰撞是真的時,它會減去100分,但不成功。劇本咆哮,如果從比分和死亡腳本。任何幫助將非常感激。團結腳本全局變量
得分腳本:
var gui : GameObject;
static var score : int;
Death.death = false;
function Start()
{
gui.GetComponent ("GUIText").text = "Score: 0";
}
function Update()
{
gui.GetComponent ("GUIText").text = "Score: " + score;
if (death)
{
score = score - 100;
}
}
死亡腳本:
#pragma strict
var Ball : Transform;
public var death : boolean = false;
function OnCollisionEnter (b : Collision)
{
if (b.gameObject.tag == "Ball")
{
death = true;
Ball.transform.position.x = 1.6;
Ball.transform.position.y = 1.5;
Ball.transform.position.z = 1.1;
Ball.GetComponent.<Rigidbody>().velocity.y = 0;
Ball.GetComponent.<Rigidbody>().velocity.x = 0;
Ball.GetComponent.<Rigidbody>().velocity.z = 0;
}
}
在** **更新功能,把**如果(死亡)**設定得分前檢查。 –