#Netcode for entites raycast prediction detect

1 messages · Page 1 of 1 (latest)

foggy stone
#

Can i predicted raycast detects entities? For example, client cast ray and validate hit entites in prediction system

glass barn
#

Yes. But with some caveats. If you're raycasting interpolated ghosts you want to enable lag compensation and want to use PhysicsWorldHistorySingleton to get correct physics world.

foggy stone
# glass barn Yes. But with some caveats. If you're raycasting interpolated ghosts you want to...

oh, thanks!

What can you say about this example: I use raycast in the client’s system, although for now I get it from physicsWorldSingleton.CollisionWorld, but that’s not the point, raycast is detected in the client system in SimulationSystemGroupe, registers and sends ghostID in the form of rps to the server there, the server, in turn, creates a raycast tag for the ghost entity according to the ghost ID, replicates the RPS to clients with this ghost ID, and client repeat logic from server rpc recive system and validate entity by ghost id like server logic(create raycast tag), and then in the prediction system the entities are validated by the tag, for example, start a ghostfield timer on the entity, am I doing it right?

glass barn
#

Things are a bit unclear. "raycast tag", "client repeat logic from server rpc recive system" repeat what exactly. What you're doing is not really great for cases where you want to predict the logic on the client. I'm not sure what you're trying to achieve, so maybe start there first. If you generally want to predict things you derive the raycast from client input from the inputCommands. If it's something you don't want to predict you can send off one of event to server through RPC or by field in command and let the server deal with the logic and replicate back the state change.

foggy stone
# glass barn Things are a bit unclear. "raycast tag", "client repeat logic from server rpc re...

in your last sentences about RPS you described exactly my logic, but slightly modified.
Look, the client raycasts the ghost, and when he pointing it, I send the ghost ID from hitEntity to the server so that it, in turn, replicates this event to other clients, am I doing this correctly, or is it not necessary to use rps here and you can get by with some netcode components that auto-replicate to other clients during a raycast event according to ghost?

glass barn
#

Again, not sure what you're trying to fully accomplish. Sure if it's something that's not happening on a continuous basis and should not be "cheat proof" you can RPC a hit to the server which will set a ghost field of the entity that then gets replicated to all entities.

molten crypt
#

from what i'm understanding of the discussion, none of this has anything to do with prediction.

the prediction system generally is for the client and server to run the same code, and rather than wait for the server to respond the client just continues the simulation without waiting. When the results are different, the server is authoritative so it overwrites what the client expects.

For the situation you described to be using prediction, both the client and server would be running the raycasts, the server will always be the source of truth, but the client just doesn't have to wait for the response.

foggy stone
# molten crypt from what i'm understanding of the discussion, none of this has anything to do w...

Thank you for your answers!!! I understand that you can send an RPS to the server so that the server changes the ghostfield data, and on the client side automatically receive a snapshot from the server, but there are some misunderstandings on how to properly make a raycast system for ghosts, so that you can pointing a ghost once and start some process on the ghost immediately, and not wait for a snapshot from the server in the update. Process, for example, replicate changing material on ghosts by raycast

glass barn
foggy stone
# glass barn So what you're saying is more something you want predicted then. What you do is ...

Yes, this seems to be exactly what I should have guessed) As I understand it, you propose to use IInputСommandData (I didn’t understand a little about the command you were talking about, but maybe this is it), which will store the mouse position and the boolean variable click, this buffer will be replicated to clients and the server, and raycast will already occur in the prediction system, right?

glass barn
#

Yes IInputCommandData creates the CommandData buffer with some codegen behind the scene. The buffer is sent to the server, it needs to be explicitly marked with ghostFields to be synced to other clients if you want to run prediction for non local clients as well.