How can I access a bullet that has been released? For example, to change the color of the bullet at the time of flight.
Does this work if i use models as bullets?
I’m using fast cast for my mech game and I’m having a few problems I just want to know if it’s me or just limitations of the module.
My mech character can wield up to 4 guns simultaneously and fire simultaneously. In studio this is not an issue but in live servers even having only two players with the same loadout makes ping start to skyrocket.
Do we have any stress test references to see if it’s just me or limitations of the module?
Probably worth noting that the weapons have a pretty high fire rate of around 1 shot every 1/100 of a second.
I find it hard to believe that fast cast would have trouble with 8 high fire rate guns so I’m hoping it’s just me and my terrible code…
Fast cast doesn’t use remote events or deal with networking at all so it should be up to user implementation.
Remote events is usually what causes Ping to sky rocket depends on rate and the amount of information you are sending.
Also automatic replication from server → client can cause ping to sky rockets which I have learnt from @Alvin_Blox problem, ex: creating part from server.
Perhaps you are creating the bullets on server with part cache being on the server?
Well one thing may have been that each gun had a part cache of 500 rounds. I brought this down to 50 as I suppose that was an extreme overestimate.
However, I’m not sure what you mean by
Aren’t bullets meant to be apart of part cache on the server?
Nope, not necessarily. For my game the fastcast is on the client to handle the visuals only.
If it is on the server then everything has to replicate to the client including the bullets projectile motion for every position and orientation changes.
Vs telling the client once to create the bullet and then letting the client simulate by itself without needing the server to tell it every position and orientation change as the bullet travels.
I recommend you try it out yourself and see if it makes a difference.
This method of using fast cast on the client for client effects I took notes from FPS framework 2.
Isn’t this method vulnerable to exploiters though?
Also you mention the client handles the visuals. But if the client handles the visuals, how will the client see other clients bullets?
You could do this from detecting when the player shoots the gun, then the server will send data’s of the bullet (e.g: Origin, Direction, Velocity, etc) from the player that shoots to other players to draw the visuals (e.g: bullet model, bullet trace, etc), so basically
Client → Server → Other Clients
i can concur. Beastybeasty145’s comment is very useful for the task in my hand.
The issue appears to be workspace being nil.
What’s happening here? Do bullets have to be parented to something specific?
I decided to go with your advice and I managed to get some really interesting results. Send-Receive rates of under 1KB/s for both clients on both rates. However my only issue now is that spread is of course randomly generated which means that if the spread isn’t accurate enough for the receiving client, the attacking player will have killed the client but the defending client would be fine which is less than ideal. Thanks for the advice, Ill do my best to develop this system but I am not without my concerns as I am sure how to defend against exploits through this way.
If anyone wants the provided Example Gun into a direct ServerScript, you can view how I did this here!
any good way to get spirals or circular motion? I’ve read that it could be a bad idea to update the cast physics every frame. assuming at most 50 projectiles on the screen, how expensive could this be? am I better off just using traditional hit detection?
Is there any way of simulating the ray instantly?
I’ve tried figuring this out myself, but haven’t been able to…Does anyone know why when the FirePointObject on the Tool seems to either collide or be very close to colliding with another part, the bullet will fire at a completely different angle?
Sorry for the small Gif, but this showcases what I mean. You can see my first few bullets fire in random directions when touching or nearly touching another object, as well as the last few bullets. You also see one shot actually go in the correct direction when I’m further away from the object.
Is it possible to simulate air resistance and drag with FastCast?
This is a roblox issue with cursor detection sadly.
I personally have this issue with EVERYTHING thats cursor-based.
As far as I am aware there is no direct solution (I may be wrong)
You could attempt the following though.
~ Raycast from the camera origin to get the hit cframe of the mouse. (unsure if this will work.)
~ Or just detect if the gun is very close to something and make it shoot infront of the barrel by default instead of going to the cursor.
Hey, thanks for the response!
In a way, I believe I’m already doing what you’re suggesting, but slightly different. Rather than using the Cursor for getting the Mouse.Hit.Position
, I began using a Raycast from the center of the screen and then returning that position.
local function GetCenterOfScreen()
local position = Camera.ViewportSize / 2
local unitRay = Camera:ViewportPointToRay(position.X, position.Y)
local rayParams = RaycastParams.new()
rayParams.FilterDescendantsInstances = {Character}
rayParams.FilterType = Enum.RaycastFilterType.Blacklist
local raycastResult = Workspace:Raycast(unitRay.Origin, unitRay.Direction * 1_000, rayParams)
local hit = CFrame.new(raycastResult.Position)
return hit.Position
end
Although even with this, the issue still persists, unfortunately.
I was curious if you had an idea of how to get the direction forward of barrel? Currently I calculate the direction using the following equation fireDirection = (mousePoint - FirePointObject.WorldPosition).Unit
.
Additionally, for anyone else who might be curious about the issue, as my previous Gif might not have shown it off greatly, here’s a better one:
If someone is still looking for this, there’s a thread solving this issue:
Simply copy & paste the entire code block, set up the proper arguments (bullet speed, gravity, start position etc.) and use what the LaunchDirection
function returns as your direction
argument:
local CanReach,DIRECTION = LaunchDirection(..., ..., ..., ..., true)
Caster:Fire(FirePointObject.WorldPosition, DIRECTION, modifiedBulletSpeed, CastBehavior)
I would absolutely love a method to simulate once instantaneously. Similar to just WorldRoot:Raycast(), it would be FastCast:Once() that would return a hit. This way I could have FastCast hit reg on client and have a sanity check testing the entire path, including pierces and reflections if I have those implemented. I’ve tried numerous times to do hit reg on the server but the delay is very noticeable and makes gunplay awful. I’ve tried lag compensation methods such as player snapshots, but it still doesn’t beat client hit reg.