Who do I set as network owner for projectiles?

I want my projectiles to look smooth and have undelayed hit detection, but setting the network owner of the projectile to the server makes it have a noticeable “hop” as defined by the wiki article on network ownership and setting it to the player makes hit detection delayed, so what do I set it to?

Server Ownership:

https://i.gyazo.com/46e6ecdf6eef827c9fc9924a6e9cfae0.mp4

Player Ownership:

https://i.gyazo.com/8a4fe9ff06e31c3d72659426a9dafb48.mp4

5 Likes

I would think to the player shooting it so they experience their shot as a smooth motion while in the background having the server check things it hits to avoid abuse. (to handle damage that is)

Yes, but then the hit detection is ugly on the client.

1 Like

In what way exactly? The shooter’s client should be doing the hit detection smoothly and could request the server to process it, I’d say.

Look at the second video

What are you using for the motion? A ray from the client should not allow it to go through obstacles.

The client fires an event and the server does everything, it creates the projectile and uses BodyVelocity to move it.

What I would suggest is have the client create and move a bullet (smooth experience to shooter) with a ray to prevent overshooting or similar, and using the server to process whatever it actually hits, recreating the bullet on the server for other players perhaps. The moment you request the server to do anything before the whole thing is shown to the shooter they experience a delay.

1 Like

I don’t think network ownership is the way you want to go if you want projectiles to be smooth. You should let each client handle visualization for itself, no matter who fired the projectile. What I did before was this:

Step 1: Fire the projectile from the shooter’s client

  • Player fires the projectile
  • Projectile motion is displayed on this client, and right after that the server is informed
  • The client continues the motion and hit detection for the projectile
  • When the projectile hits something, remove it and perform any visual effects at the point of impact

Step 2: Have the server confirm this shot is legitimate

Depending on your game’s nature, the confirmation logic here is different.

  • Have the server confirm legitimacy of the shot
  • If legitimate, tell every client besides the one which fired the projectile the start point and direction of the shot
  • Wait for the client who fired to notify the server of a hit. Of course, make sure this hit is legitimate. If it is, tell all the other clients to destroy the projectile (stop displaying it), in case the projectile on their client didn’t hit anything or is still being visualized for any other reason
  • Do any damage involved on the server

Step 3: Visualize the projectile for all other clients

  • Client uses the origin and direction given by the server to display the projectile
  • Client handles visual effects for impact itself
  • Impact can be handled two different ways:
    • If the client has not been told where impact took place at the time the projectile makes impact on the client, then wait a very short period of time (at most maybe 0.2 seconds). If there is no notice, visualize impact. It may not be where the impact took place in the server’s opinion, but waiting too long will make it look unpleasing to the player
    • When the server notifies of impact, destroy the projectile and visualize impact wherever the server said the impact took place. If impact has already taken place with this projectile on the player’s client, do not visualize impact again for the same projectile. It will look unpleasing seeing two impacts for the same projectile, and the visualization won’t effect the gameplay anyway
14 Likes