How can I access a bullet that has been released? For example, to change the color of the bullet at the time of flight.
Without creating a script in the bullet.
Inside of the script that makes the bullet, just have it defined?
Make a folder where all of the bullets get put, and then name them based on who shot them so you can access them that way
the folder is already there) It stores a certain number of bullets for optimization. So this is not the right solution for me) A lot of bullets can be fired
( FastCast Module - FastCast API )
I did not find in the module the ability to track the bullet fired.
Caster its not a bullet. Its a module
Name the bullet something along the lines of “Userfired_BulletNumber” and then with each bullet make it auto assign a number to it and then it will make changes on the bullet accordingly.
And then clone a bullet script into the fired bullet adding the color changes you wanted etc…
how do I rename a bullet if I do not know how to access it during the event :Fire?
I have had much experience using FastCast in the past and I would say it is hands down the best way of simulating bullets on roblox.
Caster:Fire returns an active cast object that is returned on CastUpdated, you can do something like this
local ActiveCast = caster:Fire(...)
ActiveCast.UserData.Txt = "Hi"--A shared library you can store your stuff in
function OnRayUpdated(Cast, ...)
--(...) is other stuff
print(Cast.UserData.Txt)--prints "Hi" because it was set after you casted it
end
edit: definitely don’t create a script in the bullet, it uses a library called PartCache to create a cache of x amount of bullets, the more bullets you have, the more processing power and memory is required to process useless inactive bullet objects.
edit 2: Here is the docs for everything in the ActiveCast FCR object ActiveCast - FastCast API
I can’t disagree, FastCast is probably the best thing that can be used to simulate bullets. The optimization of this module is so good that it allows you to create really large-scale battles without fear that when releasing more than 100 bullets at the same time there will be some visible delays.
My example: Видео 01-09-2022 23:14:46.mp4
Thank you, your answer helped!
Haha, sorry I couldn’t help you. I didn’t quite understand what you meant
Where is the cosmetic bullet’s CFrame/position being changed (during the raycast simulation)? How would I go about modifying this? (I am trying to create a projectile which rotates as if an AngularVelocity was present, but it seems like the CFrame is being set in a loop, I can’t find where it’s being set.)
the cosmetic bullet’s CFrame is being changed in the Cast.LengthChanged event
api for this method is found here
https://etithespir.it/FastCastAPIDocs/fastcast-objects/caster/#rbxscriptsignal-lengthchangedactivecast-vector3-vector3-number-vector3-instance
you can store the current rotational CFrame in Cast.UserData and increment it in LengthChanged
caster.LengthChanged:Connect(function(cast, lastPoint, segmentDirection, segmentLength, segmentVelocity, cosmeticBulletObject)
--rotate the RotCF
cast.UserData.RotCF *= CFrame.Angles()--rotation in one frame, make sure to DT filter somehow
--apply the RotCF to your positional CF before you set the cosmeticBulletObject.CFrame
cosmeticBulletObject.CFrame = positionalMath * cast.UserData.RotCF
end)
to learn how to properly position a CosmeticBulletObject, use the FastCast example gun
You’re right, I completely forgot that I copied the code from the gun. I thought it was integrated. Thanks!
When I’m using FastCast, the raycasting seems inaccurate. However, the cosmetic bullet’s trajectory seems normal. The cosmetic bullet will go through a character, but an OnRayHit event won’t fire. Does anyone know why this would happen? I have an ignore list for the player’s own character, and the tool. This typically happens when my camera is not at a “standard” angle.
the cosmetic bullet isn’t where the raycast is fired, hence the name “cosmetic bullet,” the way FC works is by creating an invisible “code bullet” (see what I did there)
this “code bullet” isn’t a physical part in the game, and its up to the programmer to properly position the cosmetic bullet
you can see the real path of the bullet with FastCast.VisualizeCasts
https://etithespir.it/FastCastAPIDocs/fastcast-objects/fastcast/#boolean-visualizecasts
Figured out the problem, FastCast can’t handle server lag since it connects to RunService. Just calculate the CFrame of a non meshpart on the server and get the appearance of the meshpart on the client