Anyone know of a bool that I need to turn on/off as when I attach an actor (pawn) the attached actor does not have its takedamage event called. What happens is the actor that it is attached to gets called instead.
try looking at the hoverboard.I think I pawn takes damage when riding it.
Probably have to override TakeDamage() of parent.
from the hoverboards takedamage
// pass damage to driver
if (Driver != None)
{
Driver.TakeDamage(Damage, EventInstigator, HitLocation, Momentum, DamageType, HitInfo, DamageCauser);
}
Thanks for the suggestions guys.
I need to distinguish between the attached actor and the actor its attached to (which has the event triggered) and ensure the correct takedamage event is processed as I’d call the attached actor’s takedamage ONLY if the hit was on that actor.
The hoverboard passes all damage to the driver, it doesn’t determine if the driver was actually hit and not the hoverboard … that’s my understanding.
You might be able to determine that through the owner of the component that was hit. Something like this:
//this is in the hoverboard (or whatever your class is)
function TakeDamage(int DamageAmount, Controller EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser)
{
if (HitInfo.HitComponent != none)
{
if (HitInfo.HitComponent.Owner == self)
{
//hoverboard was hit (or whatever your class is)
}
else if (Driver != none && HitInfo.HitComponent.Owner == Driver)
{
//driver was hit (in case of hoverboard)
// pass damage to driver
Driver.TakeDamage(Damage, EventInstigator, HitLocation, Momentum, DamageType, HitInfo, DamageCauser);
}
else
{
//something else was hit
}
}
}
A good suggestion except all info for the HitInfo is none, tried the material, physmaterial and bones as well. The damage is caused by a projectile, so takedamage should be generated via the engine through the projectile explosion.
So I thought I’d create a small test map to test this further as its quicker to load etc then normal game map so wtf happens the attached actor has its take damage event called not the actor its attached to. Huh, its the same script, and the actors are spawned through kismet that I copied from the game map to the new test map.
Don’t expect anyone to explain that, I’ll try and figure that out cause if I can copy back to the game map then issue is solved, mind you any suggestions as to why the hitinfo might have none ?