FastCast projectile goes through wall instead of ricocheting

Video reference: Watch ricochet bugged | Streamable

  1. What do you want to achieve?
    Stop the FastCast projectile from going through the wall and have it ricochet as it should.

  2. What is the issue?
    FastCast projectile has the chance to go through the wall and hit a part on the other side before ricocheting

  3. What solutions have you tried so far?
    I have tried referencing other people’s scripts and looking through the DevForum to find a solution to my answers but I have come up empty-handed. I am pretty lost on what to do.

I am using the latest FastCast version.

FYI
Green spheres mean the cast cannot ricochet,
Red spheres and linehandles mean the cast can ricochet

 local ricochetNormal = cast:GetVelocity().Unit (2*segmentDir.Unit:Dot(rayResult.Normal)*rayResult.Normal)

 cast:SetPosition(rayResult.Position)
 cast:SetVelocity(ricochetNormal*cast:GetVelocity().Magnitude)
4 Likes

I also came across this issue with my guns. Its due to how the bounce angle is calculated, generating almost another straight trajectory and piercing

Since i am not the brightest at math, my cheap solution was just making min and max bounce angles, and checked if the result of this function didnt exceed it

local function GetHitAngle(Normal, RayDir)
	local HitAcos = math.acos(RayDir.Unit:Dot(Normal.Unit))
	local HitAngle = math.deg(HitAcos)

	return HitAngle
end

HitAngle should return a number between 90 and 180

I have noticed that when HitAngle returns 170+ is when it tends to go through, so you may set your max bounce angle near that.

4 Likes

Alright, I’ll try this out to see if it works for me

1 Like