sure..if it helps improve the system..thanks..btw, im in isolation due to covid, might take a while to update it.
Viewing post in Vehicle Add-on for Invector (Revive) comments
This was useful to me, since I have a multi-scene game and the player is persistent across scenes, so can't directly link to vehicle.
// add this to every car.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CarControllerConfigurer : MonoBehaviour
{
private V_CarControl myCar;
private GameObject myPlayer;
// Start is called before the first frame update
void Awake()
{
RegisterPlayerToCar();
}
public void RegisterPlayerToCar()
{
// public method so you can call from onTriggerEnter when close to car, in case onAwake has not been called (e.g. player respawn)
myCar = this.gameObject.GetComponent<V_CarControl>();
myPlayer = FindObjectOfType<PlayerReferenceManager>().gameObject;
myCar.Player = myPlayer;
}
}
// add this to the player, it's just an empty class to make it discoverable across multiple different kinds of players.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerReferenceManager : MonoBehaviour
{}