Hello,
(I am not a native english speaker so there may be errors in my writing)
I am having trouble with the car customization script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CarPartsChanger : MonoBehaviour
{
public List _parts;
public GameObject SBumperF;
public GameObject SBumperR;
public GameObject SHood;
public GameObject SSpoiler;
[System.Serializable]
public class Parts
{
public GameObject Part;
public string PartType;
public int PartID;
public bool isMounted;
}
public void PartChooser(int K)
{
foreach (Parts parts in _parts)
{
for (int i = 0; i < _parts.Count; i++)
{
if (parts.PartID == K)
{
parts.isMounted = true;
}
if (parts.isMounted)
{
parts.Part.SetActive(true);
}
else
{
parts.Part.SetActive(false);
}
if (parts.isMounted && parts.PartType == "BodyKit")
{
SBumperF.SetActive(false);
SBumperR.SetActive(false);
}
else
{
SBumperF.SetActive(true);
SBumperR.SetActive(true);
}
if (parts.isMounted && parts.PartType == "Hood")
{
SHood.SetActive(false);
}
else
{
SHood.SetActive(true);
}
if (parts.isMounted && parts.PartType == "Hood")
{
SSpoiler.SetActive(false);
}
else
{
SSpoiler.SetActive(true);
}
}
}
}
}
The problem I’m having is that it doesn’t work as intended, ie the aftermarket parts appear, but I can’t remove unecesery parts like for a bodykit, the script doesn’t remove the stock bumpers, or the other body kit I have doesn’t remove itself when I select the first bodykit.
Thank you in advance.