Preventing projectile delay?


#1

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!


#2

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


#3

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:


#4

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.


#5

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.


#6

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?


#7

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.


#8

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


#9

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.


#10

Sorry, still wrapping my head around it.

Create the Projectile via :FireAllClients I assume?

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


#11

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


#12

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?


#13

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


#14

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?


#15

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.


#16

What if something intersects the bullet midflight


#17

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.


#18

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


#19

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


#20

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.