hitinfo.HitEntity seems to always be null whenever a BasePlayer gets attacked. I've tried with a stone hatchet, and a thompsonCode:object OnEntityAttacked(MonoBehaviour entity, HitInfo hitinfo) { if (hitinfo == null) { Print("No hit info at all"); return null; } if (hitinfo.Initiator == null) { Print("Attacker is null"); return null; } if (hitinfo.HitEntity == null) { Print("Defender is null"); return null; } }
When a player gets hit, and starts bleeding, i get a buuuunch of calls on OnEntityAttacked, with the DEFENDER being null...
Am i doing somethiong wrong....
[DOUBLEPOST=1423527215][/DOUBLEPOST]Its very strange, that when a player is bleeding, cold, or going through radiation damage, HitEntity (the defender) is null.... So, what is being damaged.
OnEntityAttacked not giving me defender
Discussion in 'Rust Development' started by ColonelAngus, Feb 10, 2015.
-
oops sorry nm
[DOUBLEPOST=1423528309][/DOUBLEPOST]why do you use hintinfo.HitEntity ?
and not entity ? -
"entity" isn't a property of the Assembly-CSharp/HitInfo class
-
MonoBehaviour entity
-
and how do i get the BasePlayer from that?
-
trying it just like that, dunno if it will work , but normally it will:
Code:object OnEntityAttacked(MonoBehaviour entity, HitInfo hitinfo) { var player = entity as BasePlayer; if(player == null) { return; } Puts(player.displayName); }
-
Alrighty... wasnt sure if you could just cast it.
-
Wulf Community Admin
We've also added back OnPlayerAttack, if that's of any use to it.
-
That did work Reneb. Thanks.
Cool. Thanks Wulf