Bullet deflection doesn't work with bullet drop

so I’ve got bouncy bullets that deflect when they hit a surface
however i need help making them work with bullet drop

the deflection works if you shoot at a wall, but if you shoot the ground the bullet goes through the baseplate, but it still returns as it was ‘reflected’

if not reflected then
    local normal = ray.Normal
    local currentNormal = bullet.CFrame.LookVector

    local reflect = (currentNormal - (2 * currentNormal:Dot(normal) * normal))

    bullet.CFrame = CFrame.lookAt(bullet.Position, bullet.Position + reflect)
							
    reflected = true
	return
end			
1 Like

bulletydrop is Vector3.new(0, -bulletLifespan, 0)

help has still not been found, but this is how it detects hit collisions

	local ray = workspace:Raycast(bullet.CFrame.Position, bullet.CFrame.LookVector * 7 + Vector3.new(0, -bulletLifespan, 0), raycastParams)

the red line is the ray visualized and it looks perfectly identical to how the bullet moves

instead of reflecting off the ground it just goes through the ground (transparent baseplate)

this only happens at certain angles though, sometimes it reflects the bullet well off the ground

Try playing around with the RaycastParams maybe? I’d do something like this

local newBullet = {}
local BlackList = {} -- things you want the bullet to ignore (I assume nothing)

newBullet.Params = RaycastParams.new()
newBullet.Params.FilterType = Enum.RaycastFilterType.Exclude
newBullet.Params.FilterDescendantsInstances = BlackList 

local ray = workspace:Raycast(bullet.CFrame.Position, bullet.CFrame.LookVector * 7 + Vector3.new(0, -bulletLifespan, 0), newBullet.Params)

that is not the problem buddy, the only thing thats ignored is the players character

bruh just double-check your raycasting parameters to ensure they are set up correctly.

additionally, If your bullet is moving too fast, it’s possible that the raycast could miss the collision with the BasePlate so check that aswell

also, add some debug information to your script to help diagnose the issue. Print out the results of the raycast to see if it’s hitting anything, and check if the BasePlate is included in the results

other than that, It’s a dead end for me due to the small amount of code given

providing more context or additional sections of your code might help in identifying the problem more precisely. We’re not really able to help you rn which is why you’ve been left hanging for 4 days.

i think the issue is that the bullet is in the ground and then it tries to reflect, which causes it to skip hit detection and then the next frame moves if out of the ground

So if I understand correctly, the bullet is embedded in the ground before it attempts to reflect, causing it to skip hit detection, right? In this case, make sure that when you spawn the bullet, its SpawnPos is above the ground. you can ensure this by either spawning the bullet at a height above the ground or by checking for collisions immediately after spawning and adjusting its position accordingly

actually, I think I need to reposition the bullet so that it goes where the hit intersects, so that it can reflect properly

if not bullet:GetAttribute("Reflected") then
		local distanceInGround = (ray.Position - bullet.Position).Magnitude												
		bullet.CFrame = bullet.CFrame * CFrame.new(0, bulletLifespan, distanceInGround)

still doesnt work though

this is what moves the bullet

bullet.CFrame = bullet.CFrame * CFrame.new(0, -bulletLifespan, -7)

bbb please help me with this problem