Download

The right way to implement suppression mechanic over network

So I am trying to implement a suppression mechanic for shootergame. The basic idea is that you have a radius around the players that if a shot (i.e. a linetrace in this case) overlaps the radius then the players view is obscured a little (i.e. you play around with the post-processing etc).

Now this has to happen over the network. So thats the biggie I think.

Currently I have the line trace information for when the radius is broken (a sphere component on the player, using linetracemulti to trace by channel and getting the overlap on the sphere from that). Right now I’m just calling a blueprint event with that information.

So what I think I need to do from here:

  • Pass the hit from the client weapon code to the server via RPC call to validate
  • Handle the call on the server and verify that the actor hit does indeed handle suppression
  • Update a suppression value on the suppressed object, with rep notify
  • When the client receives the rep notify, update the post processing according to the new value

Now I particularly want to handle some of this from blueprint, at least until I’m happy with the functionality. So I’m thinking that the best bet is to do the whole list from blueprint. Which is what I’m currently trying to implement.

Does that sound reasonable?

One thing that occurs to me is that I can save network bandwidth by checking that the actor does actually handle suppression BEFORE sending the RPC call to the server to actually run the suppression code.

Anyone got any pointers for implementing this?

What you said sounds reasonable except for the blueprint part. For someone that knows how to code I see no reason to use it for any system level gameplay work, but that’s up to you of course. Maybe you’re making another video out of this for the masses :D.

For your last two questions I’m guessing you want to validate your client to server rpc call to verify that its needed?
Are you asking if at client time do you know if what you hit is part of the sphere to suppress the player?
If so, it shouldn’t be difficult to find the attached actor for the suppressed sphere as a parent actor or parent component from the HitResults hit actor or hit component.

I am working on some features for an “advanced shootergame” sort of thing yeah. But its mainly for my own amusement too right now.

So I’ve got the suppression kind of working (with a few bugs I’m working on right now).

I wanted to use blueprint just so I can show my students how to call into blueprint from C++ classes to be honest. Plus its a bit more flexible regarding component usage etc.

So one thing I’m noticing, is that a float value that is set to rep_notify(sp?) doesn’t seem to get its replication notify called if its a local only object (i.e. its on the local host of a non-dedicated server). That seems a tad awry really, because I’ve had to actually call it myself instead.

The other issue I’ve got, is that I can’t seem to find a way to reliably get all my cameras. I’ve got a first and a third person camera toggle going on, but I want to update the suppression post-processing values on both cameras (so when you switch view they sync up). I’ve added a “GetThirdPersonCamera” to my character class. So I can get that one. But how do you actually get the camera for first person view? I’ve not seen it anywhere :slight_smile:

Will post a video once I’ve cleaned some stuff up. I think it should be quite a fun mechanic.

For rep notifies its very common to have a format like




void UpdateFoo()
{
   foo++;
if(HasAuthority())
{
OnRep_Foo();
}

}

void OnRep_Foo()
{
 // dothings as result of foo changing.
}



If the cameras are still attached to the player you can just look for all the camera components. Checkout Aactor::CalcCamera for some code.