Flashcast - a fine-grained alternative to FastCast

how the heck is the file corrupted lol

2 Likes

How would you add a physical bullet?

1 Like

Personally, How I would go about this would be to get the position the raycast hits, and then calculate the trajectory using the starting position and the ending position. And just make a bullet simulation that follows the trajectory

1 Like

The solution skelworks explained is what I’d do, you can take a look at the examples to see how you could implement it.

I was wondering if someone could give me an idea of how I should go on about creating visuals for the bullets, how do I make the visuals on the client while having the cast on the server that is if it is even posible. :thinking:

EDIT:
I figured it out, I made sure the bullet isn’t rendered on the server but rather spawn the raycast there, and then I fired all clients to do the same raycast alongside sending what time the bullet was created and then using the bullet:move(), I resynced the visuals with the server so the visual bullet hit about the same time as the server. :grin::+1:

image

Hello! Could you please share how you achieved this? Thanks.

Yes, :happy3:

I have a moduel script “ToolHandler” which fires from the client conencted to my inventory system:

And from it, the visualization on the client gets fired this is using a bindable event.
And the client creates its first cosmetic bullet, as well as telling the server to do the logic.

ClientTime refers to the time the bullet was created and the createVisualBulelt function is just using the flashcast module to create the bulelt itself, it returns flascast and the bullet:

And the server does the exact same thing but without the visual parts, just the raycast and the hitscan, but the important thing here is that It fastracks the bulelt to catch up with the client using flascast:stepBullet(), additonally it also fires all other clients except for the one that shot the bullet since the first one already has its bulelt visualized.

Lastly, the bulelt gets replicated on the other clients and they also step the bulelt forward from the initial client’s start time.

Here is with time stepping and without:

Without:
image

With
image

The diffirence here is pretty small but thats because it was only one bullet with only a baseplate, in a real senario there will be higher server latency, so this ensures the they are well synced.
I know this is a handfull and my scripts are pretty messy, so feel free to ask any questions, and I hope it was helpfull. :tongue:

1 Like

Hello, thank you this has been very helpful. I was curious about the functions BeforeStep, gravity on the server side and client side, what are they actually doing? And is the UpdateModel just moving the bullet to the correct position? Thank you so much.

Yes basically, gravity just makes it so the bullet is affected by gravity.
and beforestep is just some calculations I want to do before the bullet steps. :+1:

Here it is on the server:

And here it is on the client:


PS, IF YOU CHANGE HOW THE GRAVITY AFFECTS THE BULLET MAKE SURE ITS THE EXACT SAME FOR BOTH OF THEM (I WILL LATER PROBABLY CHANGE THE GRAVITY FUNCTION INTO A MODULE SCRIPT SO I CAN USE THE SAME CODE BASED ON A SETTING INSIDE THE GUN MODEL TO AVOID THEM BEING DIFFERENT)

1 Like