Spawning Projectile Replication

Hello. I am trying to make a shooter. I am spawning projectile perfectly but replication is the problem. Where should I make the events, on PlayerController or PlayerCharacter or ProjectileBlueprint? I tried all but got confused and I got nothing. I can’t show client’s projectile to server.

Can anyone help?

Hey w0hoho,

This is how I would do it, which includes when the projectile hits something as well:

To spawn a projectile from the client you will need to create a run on server event that the client will call, and on that event you have to spawn the projectile. Something like this:

Tell me if you have any questions!

Hey Langley, thank you for you answer. It works but there is only one problem: Server shoots where the mouse cursor is but client shoots only one point and I use this for spawning projectile. Can you tell me where is the problem?

Thanks for the answer but I need it more complicated than that. Kyle knows my issue. Thanks again.

How do I do that? I can only think of ‘get player controller’. I am making this on character blueprint. I tried making a ‘player controller bluerprint’ variable but that didn’t work either.

If you always use GetPlayerController 0 to get the controller reference, the server is only ever going to do the calculation from one controller, meaning one of the controllers (not 0) will have bad calculations, as its using the wrong controller to calculate their trace.

When using the controller, make sure to get a reference to the controller that the character who is shooting the projectile is using.

Can anyone help?

You right click in the Character and “Get Controller”. Cast the result of that into Player Controller.

Do you mean this?

112832-10-28-2016+10-22-27+am.png

UE4 has a ton of documentation on the beginner aspects of using Blueprint. You can follow these tutorials and not have to rely on the AnswerHub for every single question you have and instead can look through and find it, as something like getting the PlayerController is very basic.

[Blueprints Visual Scripting in Unreal Engine | Unreal Engine 5.1 Documentation][2]

[Introduction to Blueprints Visual Scripting in Unreal Engine | Unreal Engine 5.1 Documentation][3]

[New Blueprint Tutorials - Unreal Engine][4]

[Blueprint basics - Unreal Engine][5]

I am sorry but I know how to make this. I tried this yesterday on my own but client still doesn’t work like server. That’s why I asked you, because you said that. You don’t need to send me tutorials and I need to rely on AnswerHub on this.

Did exactly the same, now server can’t shoot where mouse is. My system works like I want, I shown above but client can’t shoot it, why it is not working?

Tutorials have all of the information you need, which is why I linked them.

Here is an example project to shoot projectiles at the mouse location. This is also all that I can do to help you, so please take it on yourself to look at those tutorials and follow them. They explain in some way everything you need to solve this problem.

Thank you I downloaded it.

That’s where you misunderstood me. I didn’t ask that I need to know how to shoot projectiles in mouse location. I’ve done that. I just need to know how to work it with client in a multiplayer game with non-dedicated server.

I’ve done it in my single player game and now my multiplayer game. Server side works but client side doesn’t work. I need to know why and how to fix it. Those tutorials have nothing to do with it.

The answer is above.

I had to make the SpawnProjectile multicast for it to appear on the client. Any idea what I’m doing wrong?