Need help for a split screen multiplayer racing games
So I have a project due for school and i'm having some major trouble with figuring out how to finish it. I'm making a split screen racing game and I need to assign separate controls to both cars and add a checkpoint/lap system. I imported the default unity vehicle asset and duplicated the car, so they use the same script to drive the vehicle. However, they both move at the same time when WASD or the direction keys are pressed. I tried editing the input manager by creating an extra Horizontal and Vertical Axis but that didn't seem to fix my problem.
As for the checkpoint/lap system I used the following code that I found online
Laps:
using UnityEngine;
using System.Collections;
public class Laps : MonoBehaviour {
// These Static Variables are accessed in "checkpoint" Script
public Transform[] checkPointArray;
public static Transform[] checkpointA;
public static int currentCheckpoint = 0;
public static int currentLap = 0;
public Vector3 startPos;
public int Lap;
void Start ()
{
startPos = transform.position;
currentCheckpoint = 0;
currentLap = 0;
}
void Update ()
{
Lap = currentLap;
checkpointA = checkPointArray;
}
}
Checkpoint:
using UnityEngine;
using System.Collections;
public class checkpoint : MonoBehaviour {
void Start ()
{
}
void OnTriggerEnter ( Collider other )
{
//Is it the Player who enters the collider?
if (!other.CompareTag("Player"))
return; //If it's not the player dont continue
if (transform == Laps.checkpointA[Laps.currentCheckpoint].transform)
{
//Check so we dont exceed our checkpoint quantity
if (Laps.currentCheckpoint + 1 < Laps.checkpointA.Length)
{
//Add to currentLap if currentCheckpoint is 0
if(Laps.currentCheckpoint == 0)
Laps.currentLap++;
Laps.currentCheckpoint++;
}
else
{
//If we dont have any Checkpoints left, go back to 0
Laps.currentCheckpoint = 0;
}
}
}
}
Im kinda confused as to where to assign these two scripts. I assigned them to both of the cars, but whenever the checkpoints that i made are passed, the lap counter in the inspector doesn't change.
What are some step by step instructions to figure these two things out?
Your answer