Car customization should fully work
This commit is contained in:
@@ -1,25 +1,92 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cinemachine;
|
||||
using Unity.Burst.Intrinsics;
|
||||
using UnityEngine;
|
||||
|
||||
public class CarLoader : MonoBehaviour
|
||||
{
|
||||
public GameObject Hotrod;
|
||||
GameObject playerCar;
|
||||
public GameObject[] Cars;
|
||||
string carType;
|
||||
string carColor;
|
||||
public Material[] Colors;
|
||||
public CinemachineVirtualCamera vcam;
|
||||
void Start()
|
||||
{
|
||||
playerCar = GameObject.Find("Car Data").GetComponent<CarData>().playerCar;
|
||||
|
||||
replaceCar(Hotrod);
|
||||
carType = GameObject.Find("Car Data").GetComponent<CarData>().carType;
|
||||
carColor = GameObject.Find("Car Data").GetComponent<CarData>().carColor;
|
||||
|
||||
foreach (GameObject car in Cars)
|
||||
{
|
||||
if (car.name == carType)
|
||||
{
|
||||
replaceCar(car, carColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void replaceCar(GameObject car)
|
||||
void replaceCar(GameObject car, string color)
|
||||
{
|
||||
Transform carTransform = car.transform;
|
||||
car.GetComponent<carcontrolv2>().enabled = true;
|
||||
car.GetComponent<AgentControllerV6>().enabled = false;
|
||||
|
||||
playerCar.transform.position = carTransform.position;
|
||||
playerCar.transform.rotation = carTransform.rotation;
|
||||
playerCar.transform.localScale = carTransform.localScale;
|
||||
vcam.Follow = car.transform;
|
||||
vcam.LookAt = car.transform;
|
||||
|
||||
if (color == "Default")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (color == "Black")
|
||||
{
|
||||
car.GetComponent<ChangeCarColor>().ChangeColor(Colors[0]);
|
||||
}
|
||||
if (color == "Blue")
|
||||
{
|
||||
car.GetComponent<ChangeCarColor>().ChangeColor(Colors[1]);
|
||||
}
|
||||
if (color == "Brown")
|
||||
{
|
||||
car.GetComponent<ChangeCarColor>().ChangeColor(Colors[2]);
|
||||
}
|
||||
if (color == "Gray")
|
||||
{
|
||||
car.GetComponent<ChangeCarColor>().ChangeColor(Colors[3]);
|
||||
}
|
||||
if (color == "Green")
|
||||
{
|
||||
car.GetComponent<ChangeCarColor>().ChangeColor(Colors[4]);
|
||||
}
|
||||
if (color == "Orange")
|
||||
{
|
||||
car.GetComponent<ChangeCarColor>().ChangeColor(Colors[5]);
|
||||
}
|
||||
if (color == "Pink")
|
||||
{
|
||||
car.GetComponent<ChangeCarColor>().ChangeColor(Colors[6]);
|
||||
}
|
||||
if (color == "Red")
|
||||
{
|
||||
car.GetComponent<ChangeCarColor>().ChangeColor(Colors[7]);
|
||||
}
|
||||
if (color == "Turquoise")
|
||||
{
|
||||
car.GetComponent<ChangeCarColor>().ChangeColor(Colors[8]);
|
||||
}
|
||||
if (color == "Violet")
|
||||
{
|
||||
car.GetComponent<ChangeCarColor>().ChangeColor(Colors[9]);
|
||||
}
|
||||
if (color == "White")
|
||||
{
|
||||
car.GetComponent<ChangeCarColor>().ChangeColor(Colors[10]);
|
||||
}
|
||||
if (color == "Yellow")
|
||||
{
|
||||
car.GetComponent<ChangeCarColor>().ChangeColor(Colors[11]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user