Hello to all forum users, tell me how to get a "Session" of the player dealing damage.
Getting session of attacking player?
Discussion in 'Hurtworld Development' started by vladbkaaa -D-, Aug 13, 2017.
-
You could just get the string of the player name using the entitySource.GetDescriptionKey or get the GameObject of the entity that caused damage, then iterate through the game sessions and match whichever variable you use to an existing session and return that session.
for GameObject use: sourceData.EntitySource.gameObject == session.WorldPlayerEntity.gameObject
for player name use: sourceData.EntitySource.GetDescriptionKey().Replace("(P)","") == session.Identity.Name
Keep in mind you will need to remove the (P) from the playername that they add in to the entity source description, when checking for matching player name. There are other more accurate ways to accomplish this other than the simple Replace method above.Last edited by a moderator: Aug 15, 2017 -
The EntityEffectSourceData has the field EntitySource which contains an object of the type GameObject depending on what did the damage.
Code:var attackerSession = GameManager.Instance.GetSession(source.EntitySource.GetComponent<uLinkNetworkView>().owner);