Preventing projectile delay?

Been working on a Wand for some time now and having issues finding any solution to the projectile delay.

Currently the wand functions via the Client, in which fires an event to transfer it to a Server script - Which then finds the required Module in relation to the spell and casts it.
My issue being that upon impact, there’s a brief [but noticeable] delay of around about 1 - 2 seconds before removing said Spell, making it look sloppy.

I’ve tried all sorts of methods, none of which work effectively.
Any help would be greatly appreciated!

1 Like

Could you provide gifs of this in action so we could see it?

1 Like

I suggest you hide this delay with an animation. There’s not much you can do to shorten it - and you can only really make it less noticeable by adding animation. I am unsure of what type of animation you could use since I’ve not seen your code in action.

So, I also ask:

2 seconds is enormous amount of time for projectile lag, you’re probably doing something wrong.

I suggest you create the projectile on client. After that, you tell the server about projectile.
After server verifies projectile, he tells all other clients to create projectile for themselves.
Clients manage projectiles themselves (each client has a copy of the projectile), while Server manages hit detection.

8 Likes

Is there a way to not have the server projectile fakes to be replicated to the clients? The server projectiles would be invisible but the only thing the clients need to know are when collisions happen, not where server side projectiles are or how fast they are moving.

1 Like

You’d have to delete the client-sided projectile after server-sided one is spawned.
Although, I see no issues with why wouldn’t you want to replicate projectiles to the client?

The other players find out about and create the bullet on the client side after the server side bullet is created not before. I don’t want to replicate the server side bullet because im already telling the clients about it with an event.

This is the best I could get, is that alright?
Notice the bounce-back as it hits the target.

Yeah mine did that too initially so I hid the server bullet. Just create it client side and tell the server to handle and announce the real collisions.

Sorry, still wrapping my head around it.

Create the Projectile via :FireAllClients I assume?

So it’d go LocalScript -> Server -> LocalScript?

Yes, that is how it works.

A simpler method would be to create the projectile normally via remotevent and just set the parts NetworkOwnership to the player who fired the projectile as soon as the projectile is parented to the workspace. This does have its drawbacks like laggy players = laggy bullets but it still works.

The latter method will mostly remove that initial lag

4 Likes

Thanking you so much!
Initially I planned to have the scripts within the actual tool itself to spare cluttering them around the game files - Is this still doable? Or would the RemoteEvent need to be in ReplicatedStorage?

I really dislike giving the players ANY network ownership, players will categorically have bad network and will make overseas expansion harder.

So, layout speaking -

First I create the Spell locally among all clients,
then I set it so when it’s .Touched or PartOnRay [Haven’t decided what one I’m using yet] It sends it to the Server?

I’ve never said that you need to even create the server-sided bullet.
You should calculate the bullets position and raycast forward to find out when will unexisting bullet hit something.
This should be done every 0.1 seconds or so.

2 Likes

What if something intersects the bullet midflight

The player creates his own bullet thats a fake, asks the server to create the real, invisible one. The server tells all the other players to create their own client side fakes. Never does a player see the real bullet collision take place.

You don’t raycast from start to end, you raycast from current position to the next one.
You get current/next position by moving the bullet towards the end by Velocity * TimePassed

So instead of a fake server bullet with physics/gravity you have a bunch of floating cframes that determine bullet position?

Makes alot of sense and keeps me from relying on actual projectile physics

Yes. The server doesn’t have reference to Bullet models.
Rather, it has reference to some values that determine the position, like:
StartPosition, EndPosition, Velocity, TimeCreated, …

Every n seconds, you raycast from current position to new position, if there’s no hit, you move the bullet, otherwise, you do whatever you want to do when it hits.

2 Likes