I’m trying to make an ping pong style game so in level 2 i have added 2 balls and i want to trigger game over only when both the balls pass beyond y axis 3.5 ::"
i’m using javascript
this is the script i’m using for the balls
“function Update ()
{
if(transform.position.y < -3.5)
{
mainGameScript.GameOver();
}
}”
and the main game script
"
unction GameOver()
{
if(score > PlayerPrefs.GetInt(“High Score” ))
{
PlayerPrefs.SetInt(“High Score” , score);
}
Application.LoadLevel("Game_Over");
}
"
this is the whole script for the ball
"var mainGameScript : MainGame;
var particles_splash : GameObject;
function Awake()
{
rigidbody.AddForce(4, 4, 0, ForceMode.Impulse);
InvokeRepeating(“IncreaseBallVelocity”, 2, 2);
}
function Update ()
{
if(transform.position.y < -3.5)
{
mainGameScript.GameOver();
}
}
function IncreaseBallVelocity ()
{
if(rigidbody.velocity.x < 14 && rigidbody.velocity.y < 14 && rigidbody.velocity.x > -14 && rigidbody.velocity.y > -14);
{
rigidbody.velocity *= 1.05;
Debug.Log("velocity: " + rigidbody.velocity);
}
}
function OnCollisionEnter(collision : Collision)
{
Instantiate(particles_splash , transform.position , transform.rotation);
audio.Play();
}"
and this is the whole script for maingame
"
var score3DText : TextMesh;
private var score : int = 0;
function Awake ()
{
InvokeRepeating(“UpdateScore” , 0.05, 0.05);
}
function UpdateScore()
{
score += 1;
score3DText.text = "Score : " + score.ToString();
}
//this is called from BonuAreaDetectionBox.js inside OnTriggerEnter()
function AddScoreForBonusArea ()
{
score += 50;
}
function GameOver()
{
if(score > PlayerPrefs.GetInt(“High Score” ))
{
PlayerPrefs.SetInt(“High Score” , score);
}
Application.LoadLevel("Game_Over");
}"
I don't see anything to answer... You should revise your question, it's hard to understand and possibly incomplete.
– Juice-Tin