- Home /
Question by
EliteHedgehog56 · Nov 17, 2018 at 01:44 AM ·
rotationpositionraceendgame
Racer positioning system and race end
Hey all, I'm making a local multiplayer whipeout/F-Zero style racing game. I have the ships, the track and basic lap/checkpoint system set up. What I'm trying to achieve now is a ship position system (1st, 2nd, 3rd, etc) and I want to end the race when the lap goal is met and get the ship's final position when they finish the race. How can I achieve this? Here's my lap and checkpoint script which is in javascript
var checkPointArray : Transform[]; //Checkpoint GameObjects stored as an array
static var currentCheckpoint : int = 0; //Current checkpoint
static var currentLap : int = 0; //Current lap
static var startPos : Vector3; //Starting position
var lapText : UI.Text;
var lapGoal : float = 5;
var isRacing : boolean = true;
var playercam : GameObject;
var endcam : GameObject;
public var Player1 : Player1;
var playerlaps : GameObject;
function Start () {
//Set a simple visual aid for the Checkpoints
for (objAlpha in checkPointArray) {
objAlpha.GetComponent.<Renderer>().material.color.a = 0.2;
}
checkPointArray[0].GetComponent.<Renderer>().material.color.a = 0.8;
//Store the starting position of the player
startPos = transform.position;
}
function Update(){
if (isRacing){
if(lapText)lapText.text = currentLap.ToString();
if (currentLap == lapGoal){
Win();
}
}
}
function Win(){
isRacing = false;
Debug.Log("Race Won!");
playercam.gameObject.active = false;
endcam.gameObject.active = true;
playerlaps.gameObject.active = false;
yield WaitForSeconds (0.5);
Player1.enabled = false;
}
Comment