1. Hello,

    I don't know if there's something similar or even if it can be done.

    Here's my question :

    If you get crushed by a car, is there a way to display the name of the driver ?

    Thank you for your help,
    Cheers,
    bLUUE
    [DOUBLEPOST=1455649790,1455415092][/DOUBLEPOST]Bump ! Anyone ?
    Thanks
     
  2. I found this in VehicleMotorEdy:
    public void OnCollisionEnter(Collision collisionInfo)
    Collision seems to be from the UnityEngine API. And it hold a GameObject. So try and convert it to....VehicleStatManager?
    I'm guessing but I hope this helps. Keep us posted on your findings PLEASE (A) ;)
    [DOUBLEPOST=1456088689,1455997176][/DOUBLEPOST]So this works:
    Code:
    var carList = UnityEngine.Object.FindObjectsOfType<VehicleStatManager>().ToList<VehicleStatManager>();
    but _passengers from VehicleStatManager is a private, and my C# is still at hobby level.
     
  3. You can do this by using the Passenger GameObject.
    Then just iterate through GetSessions().Values for their WorldPlayerEntity == GameObject and return that session for the driver of the vehicle.
    [DOUBLEPOST=1458400186][/DOUBLEPOST]Here you go.
    Code:
    private PlayerSession GetPlayer(GameObject go)
    {
       foreach(PlayerSession sesh in GameManager.Instance.GetSessions().Values)
       {
         if(sesh.WorldPlayerEntity == go)
           return sesh;
       }
       return null;
    }
    
    Code:
    PlayerSession KillerSession = null;
    if(source.SourceDescriptionKey == "EntityStats/Sources/a Vehicle Impact")
    {
       var passengers = GameObjectExtensions.GetComponentsByInterfaceInChildren<VehiclePassenger>(source.EntitySource);
       foreach(var p in passengers)
       {
         if(p.ToString() == "Roach(Clone) (VehicleController4Wheel)" || p.ToString() == "Goat(Clone) (VehicleController4Wheel)" )
                 KillerSession = GetPlayer(p.Passenger.gameObject);
       }
    }
    There's other ways to do this, this was just something quick that I knew would work, so feel free to mess with it.
     
    Last edited by a moderator: Mar 19, 2016