yes. Its an argument of the raycastresult in the RayHit event of the caster.
Not yet. I want to though, I will make that known.
I see, but I have a couple questions
Why fire the cast on the server, if you want to visualize it on the client? Doesn’t the caster:Fire() method also create a projectile because it requires the castbehavior parameter, which passes the cosmeticbulletprovider? In the module, the ‘SimBullet’ function creates a cosmeticbulletobject. You are calling that on the server. How would that work?
The cast on the server is used mainly for hit detection. Of course, you could have the client do hit detection if you wanted and have the server do a valid check. The server doesn’t create the cosmetic bullet it only creates the ray. The clients create the visual stuff. Anything visual-related, aside from the debug, is removed from the server. You do not need to pass ‘CastBehavior.CosmeticBulletProvider’ on the server. In fact, FastCast still works without it.
oh sweet! Thats what I was worried about when I was reading the fastcast module. I couldn’t find anywhere, where the module checks if the cosmeticbulletprovider/ cosmetic bullet exists
I did some testing, If you are shooting and die while shooting (With the debug gun and my own) The bullets get frozen in the air, and will not be removed. How do you solve this?
Fast cast debug gun lowers Hearbeat to 14 am I doing somthing wrong?
By not having the script simulating the shots in the tool. When you die, it deletes the tool instance and consequently deletes the FC script too. That causes all simulation to completely stop and leave the cosmetic bullets behind.
Mannnn, I wish I would have tried that! Spent hours looking at part cache, Thank you so much!
I am really proud of this module!
However, the only problem I am having with it is the fact that my bullets, when they have reached their max distance, just stay in the air and not get teleported (I am using Part Cache). Is there a way to work around this?
Perhaps I can use “GetVelocity()” for every bullet and send them far away as soon as they reach zero but I don’t know how I would implement that and as your website says, it will cause performance problems and I don’t want that in my game.
The documentation outlines the solution for this.
I’m going to assume you are returning bullets to their cache in the RayHit
method, no? If you are, this is incorrect behavior.
You can resolve the problem above and the problem you are having by returning parts to cache in the CastTerminating
event, which fires when the cast terminates in general (it always fires directly after RayHit
is done executing, I might add, because ray hitting something = that ray needs to terminate = fire CastTerminating
and terminate.)
Oh thanks! I fixed it. I should have dug deeper into this Module because I did not know that it existed or read passed it without realizing.
when will there be an option for bullet tracers? I tried making some but it comes from the sky and not even comes out of the tip of the gun but a few seconds from it?
Is there a way I can control how many times the bullet bounces? It would be very helpful!
I think there’s a function called canpierce then there should be the number 3 that’s how much times it bounces
Hey! So I’ve been scratching my head off trying to understand, but how can I delete the bullet after it exceeded the maximum Range or it hit something? The 2 closest things are
RayHit
Only when the Bullet hit something - not always hits something
CastTerminating
Doesn’t pass the object
⠀
So, any help whould be appreciated!
Edit:
Just saw the entire table, and in the CastTerminating Event you can get the bullet by indexing
Caster.RayInfo.CosmeticBulletObject
In my case, I need to do
BulletCache:ReturnPart(Caster.RayInfo.CosmeticBulletObject)
Hey there! I couldn’t find any number value in the RayPierced function. There’s the cast value, rayResult and Velocity. Where do I set the number value?
if you are using the gun example he gave theres a function:
function CanRayPierce(cast, rayResult, segmentVelocity)
-- Let's keep track of how many times we've hit something.
local hits = cast.UserData.Hits
if (hits == nil) then
-- If the hit data isn't registered, set it to 1 (because this is our first hit)
cast.UserData.Hits = 1
else
-- If the hit data is registered, add 1.
cast.UserData.Hits += 1
end
-- And if the hit count is over 3, don't allow piercing and instead stop the ray.
if (cast.UserData.Hits > 3) then
return false
end
-- Now if we make it here, we want our ray to continue.
-- This is extra important! If a bullet bounces off of something, maybe we want it to do damage too!
-- So let's implement that.
local hitPart = rayResult.Instance
if hitPart ~= nil and hitPart.Parent ~= nil then
local humanoid = hitPart.Parent:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid:TakeDamage(10) -- Damage.
end
end
-- And then lastly, return true to tell FC to continue simulating.
return true
--[[
-- This function shows off the piercing feature literally. Pass this function as the last argument (after bulletAcceleration) and it will run this every time the ray runs into an object.
-- Do note that if you want this to work properly, you will need to edit the OnRayPierced event handler below so that it doesn't bounce.
if material == Enum.Material.Plastic or material == Enum.Material.Ice or material == Enum.Material.Glass or material == Enum.Material.SmoothPlastic then
-- Hit glass, plastic, or ice...
if hitPart.Transparency >= 0.5 then
-- And it's >= half transparent...
return true -- Yes! We can pierce.
end
end
return false
--]]
end
the number 3 that’s:
if (cast.UserData.Hits > 3) then
that’s the amount of times it can bounce. the more the more times it bounces
one final question. Do I have to put it along with FastCastBehavior? If so, how?
I’ve read the docs but I’m not sure as they haven’t shown how they actually reference this rayPierce function to their caster.
I’m guessing its something like FastCastBehaviour.CanRayPierce = function()
or if i name it “CanRayPierce” it will just work?