Stuck on replicating Ammo Count data
Hey everyone, I've managed to use the First Person Blueprint template to get a basic shooter running. So far I've managed to replicate the players projectiles dealing damage on both client and server. However, when it comes down to the ammo count, it only shows up on the server.
I have replicated my variables and I have set events to Multicast or Run on Server as well as making sure they are reliable.
I've also attempted to use the whole "Switch has Authority" switch but I still have issues.
My current setup displays the ammo count as 8 for each weapon (which is what I intended as the starting ammo). My issue now lies in the successful depletion of ammo when firing the weapon. On the server/host this works just fine. The client is unable to deplete the ammo and is unable to fire the weapon.
(below) When fire is called, it checks if the player has the appropriate weapon equipped, then proceeds to check the current ammo. Respectively triggering it to release a projectile if the criteria is met.
(below) Ammo is then supposed to be depleted by the value of 1 and then it will update the ammo of whatever weapon is selected
(below) This is where you cycle with the scroll wheel to choose the weapon you want to use.
(below) When the weapon is chosen, its ammo type is then loaded into a variable so that it can be depleted.
So there we have it in its current state, only firing and depleting ammo on the server/host side.
asked Nov 11 '15 at 12:05 PM in Blueprint Scripting
Screenshot 1: You don't need to differentiate between server and clients here, just call "Server Fire" all the time. When called on a server, the server-RPC executes too (see the RPC table )
Screenshot 2: No need to execute the Deplete Ammo on every client, since the Ammo value is a replicated variable anyway. So just execute this on the server and every client should get this update. Also, I think you are trying to do a multicast call from the client, which is dropped. Only the server can do this (see RPC table).
It's easy to get confused by replication, don't feel bad about it :) I think you confused RPC and replicated variables here and did way too much work.
I suggest you only do somethink like this:
answered Nov 11 '15 at 01:36 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here