My gameobjekt is called CarController. It spawns the choosen car into the scene (this works perfectly fine). Now I also want to let the CarController follow the currentCar trought the scene because if I would do that I would have a constant gameobject in the scene which follows the choosen car so that I can easily attach my scene camera to the CarController.
Here is the code for the CarController:
`using UnityEngine;
public class CarController : MonoBehaviour
{
[SerializeField] private GameObject[] spaceshipModels;
private void Awake()
{
ChooseStarshipModel(SaveManager.instance.currentStarship);
}
private void ChooseStarshipModel(int _index)
{
Instantiate(spaceshipModels[_index], transform.position, Quaternion.identity, transform);
}
}
`
But because I am not an expert I can not figure out who to do that. So I would be glad I someone could help me with this problem
↧