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
Getting killer's name on a vehicle?
Discussion in 'Hurtworld Development' started by bLUUE, Feb 16, 2016.
-
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>();
-
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); } }
Last edited by a moderator: Mar 19, 2016