FastCast is a pretty neat module and is probably heaps better than normal Raycast so I want to implement it into my future game. Basically I only need to use it for part detection and only need ray hitted part’s point normal. (Note, that i’m not an experienced scripter)
The current/normal Raycast module lets you easily do:
local Result = workspace:Raycast(Origin, Direction, raycastParams)
and you can easily access the ‘Result.Normal’ and etc. throughout the rest of your script.
BUT with FastCast you need to do all that other stuff and without a lot of coverage online I just don’t know how to work with it and the Result only stays in the ‘OnRayHit’ function.
This is where i’m currently at:
local FastCast = require(game.ServerScriptService.FastCastRedux)
local caster = FastCast.new()
local part = workspace.Part
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Whitelist
params.FilterDescendantsInstances = {part}
local castBehavior = FastCast.newBehavior()
castBehavior.RaycastParams = params
local function OnRayHit(cast, result, velocity, bullet)
-- as far as i know this is the only place where i can work with and check 'result.Normal'
end
caster:Fire(SomeOrigin, SomeDirection, SomeVelocity, castBehavior)-- i input my own variables, but here i just wrote parameter names to make it understandable
caster.RayHit:Connect(OnRayHit) -- is this the only way i can find out result?
if result.Normal.Y >= 0 then -- I want to access the result and it's contents here - outside any functions
print(result.Normal.Y)
end
Any help is greatly appreciated, thank you! xoxo
- Tady