This is my first time making a game in Unity so my knowledge is limited.
I have made a race game for 2 players with a split screen, now I want to make a character selection menu but I have no idea where to start.
The menu has 3 cars and when both players have selected their cars I want those cars to spawn for the designated player.
EDIT: To give more information. The gameplay is finished I have a splitscreen with 2 cameras showing player1 and player2 each with their own controls.
Now I just need to figure out how to make a character selection screen.
I hope this was somewhat helpful.
Thank you.
using UnityEngine;
using System.Collections;
public class PlayerCar : MonoBehaviour {
public WheelCollider WheelFrontLeft;
public WheelCollider WheelFrontRight;
public WheelCollider WheelBackRight;
public WheelCollider WheelBackLeft;
public float maxTorque = 50f;
public Transform CenterOfMass;
public float lowestSteerAtSpeed = 50f;
public float lowSpeedAngle = 10f;
public float highSpeedAngle = 1f;
public float deceleration = 30f;
public float currentSpeed = 0f;
public float topSpeed = 150f;
public float reversalSpeed = 50f;
public bool brake = false;
public float maxBrakeTorque = 100f;
private float mySidewayFriction;
private float myForwardFriction;
private float slipSidewayFriction;
private float slipForwardFriction;
public int[] Gear;
public int currentGear;
private Vector2 pivotPoint;
public GameObject sparks;
public GameObject crashSound;
// Use this for initialization
void Start () {
SetupCenterOfMass ();
SetValues();
}
// Update is called once per frame
void FixedUpdate ()
{
CarControler ();
HandBrake ();
}
void Update()
{
EngineSound();
}
void CarControler()
{
currentSpeed = Mathf.PI*WheelBackLeft.radius*WheelBackLeft.rpm*120/1000;
currentSpeed = Mathf.Round(currentSpeed);
if(currentSpeed <= topSpeed && currentSpeed > -reversalSpeed && !brake)
{
WheelBackRight.motorTorque = maxTorque * Input.GetAxis("Vertical");
WheelBackLeft.motorTorque = maxTorque * Input.GetAxis("Vertical");
}
else
{
WheelBackLeft.motorTorque = 0;
WheelBackRight.motorTorque = 0;
}
if (Input.GetButton("Vertical") == false)
{
WheelBackLeft.brakeTorque = deceleration;
WheelBackRight.brakeTorque = deceleration;
}
else
{
WheelBackLeft.brakeTorque = 0;
WheelBackRight.brakeTorque = 0;
}
WheelFrontLeft.steerAngle = 8 * Input.GetAxis ("Horizontal");
WheelFrontRight.steerAngle = 8 * Input.GetAxis ("Horizontal");
}
void HandBrake ()
{
if (Input.GetButton("Jump"))
{
brake = true;
}
else
{
brake = false;
}
if (brake)
{
WheelBackLeft.brakeTorque = maxBrakeTorque;
WheelBackRight.brakeTorque = maxBrakeTorque;
WheelBackLeft.motorTorque = 0;
WheelBackRight.motorTorque = 0;
}
}
void EngineSound()
{
int i = 0;
for(i = 0; i < Gear.Length; i++)
{
if(Gear *> currentSpeed)*
-
{*
-
currentGear = i;*
-
break;*
-
}*
-
}*
-
float gearMinValue = 0.00f;*
-
float gearMaxValue = 0.00f;*
-
if (i == 0)*
-
{*
-
gearMinValue = 0;*
-
}*
-
else*
-
{*
-
gearMinValue = Gear[i-1];*
-
}*
_ gearMaxValue = Gear*;_
_ float enginePitch = ((currentSpeed - gearMinValue)/(gearMaxValue - gearMinValue)+0.3f);_
_ audio.pitch = enginePitch; _
_ }*_
* void SetupCenterOfMass() *
* {*
* if(CenterOfMass != null)*
* rigidbody.centerOfMass = CenterOfMass.localPosition;*
* }*
}