Damageable Object not taking damage when attached to a Player

  • Created a Damageable Object in my hierarchy called "Shield"
  • When the game starts, Shield is attached to player SHIELD:AttachToPlayer(player, "root")
  • Modified AI Turret to search for Shield in the player's attached objects and use it as target

Expected:

  • Bullets from AI Turret would apply damage to shield

Actual:

  • Bullets from AI Turret bounce away from the shield

What other changes need to be made for the object to take damage?

Here's an example recording:

Looks like changing the Weapon under "AI Activity Turret" to have "Is Hitscan" checked does result in damage being applied to the shield. Can someone help me understand why that works?

Weapons have two ways of working: When you fire a hit scan weapon it does a ray cast to instantly check if you have a collider in the weapon's line of sight, if the ray cast is successful then the weapon script processes the collider returned by the ray cast as the target. A ray cast is instantaneous, there is no time of flight and it is straight, so there is no ballistic drop on the shot. This is checked on the server side by the weapon's targetImpactedEvent.

Alternatively the weapon may spawn a projectile with an initial velocity in line with where the weapon is pointing. The weapon then has nothing more to do with things and you are waiting for an impactEvent for the projectile. The projectile has time of flight and drop.

When you check the IsHitscan box you are changing how the weapon is working and which script is being used to process the hit: You will need to identify which scripts are being used and I will guess the projectile one is not set up to work with damageables.

Thanks, ReQuad!

So that means Projectiles spawned by Weapons don't automatically apply damage on impact?

Sorry I wasn't that familiar with the default weapon behaviour, it seems core has some code associated with them that is not visible as a script. So if you are making your own custom weapons with scripts you need the info I posted before, but if you are using the standard weapons then it should work...

I just tried putting down a Damageable Hazard Barrel and shooting it with a Basic Shotgun (both Core templates) and the barrel blew up with the shotgun regardless of the hitscan settings.

I wonder if the shield is inheriting some player properties? Have you tried having just an instance of the shield (not attached to the player) and shooting it with the gun?

Another thought... is it actually hitting the shield or is it within the player capsule? Try an offset that will result in the shield being well clear of the player.