When a grenade explodes the damage goes through walls. Does anyone know how I would go about preventing this? I'm not sure how to approach this issue.
The explosion checks for players in a radius and applies damage - there are no projectiles that could hit a wall and just be destroyed on impact before reaching the player. So I'm not sure if it's even possible?
Any advice would be great
Here is the part of the grenade script that does the damage (this is from the build in grenade)
if canDamage then
local displacement = player:GetWorldPosition() - center
-- The farther the player from the blast the less damage that player takes
local minDamage = EXPLOSION_DAMAGE_RANGE.x
local maxDamage = EXPLOSION_DAMAGE_RANGE.y
displacement.z = 0
local t = (displacement).size / EXPLOSION_RADIUS
local damageAmount = CoreMath.Lerp(maxDamage, minDamage, t)
-- Create damage information
local damage = Damage.New(damageAmount)
damage.sourcePlayer = WEAPON.owner
-- Apply damage to player
player:ApplyDamage(damage)
-- Create a direction at which the player is pushed away from the blast
player:AddImpulse((displacement):GetNormalized() * player.mass * EXPLOSION_KNOCKBACK_SPEED)
end