x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Damage from client to server

Hi, when I was working on the damage i've noticed that the client can't deal damage to the server. Here's my graph: https://imgur.com/a/64hraqN What's wrong with it? Thanks in advance.

Product Version: UE 4.21
Tags:
more ▼

asked Jun 13 '19 at 10:22 AM in Blueprint Scripting

avatar image

David432
7 1 1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

The problem is that you are calling a multicast event that is being called from a client. Multicast events will only run on the client if called from a client. So the object you are passing to the server function most probably does not exist on the server. What I would advice you to do is:

  • On your attack function check if you are a client or the server. If you are a client call the server function, on server simply execute the code.

  • Run your ray traces on the server, not on the client and apply damage accordingly on server to replicate.

  • On your client simply run a simulation of the attack (particle effects, sounds, animations).

As a rule of thumb always remember that any RPC will run correctly only when called from the server. So anything you need to replicate do through a server call that then calls the corresponding RPC (in case of multicast or client), unless of course is a call to run on server.

Hope this helps as a guidance. If this info was useful please remember to mark it as the correct answer so other users can finde it easily. Make it a great day!

more ▼

answered Jun 13 '19 at 01:27 PM

avatar image

Bariudol
1.2k 24 13 29

avatar image David432 Jun 13 '19 at 03:08 PM

How do I check if I'm the client or the server? And how do I properly apply the damage?

avatar image Bariudol Jun 13 '19 at 05:13 PM

To check if you are on the server or on a client simply use the "Switch Has Authority" node. If it has authority is the server or the host player, otherwise is a client.

The way you are applying the damage seems correct at first glance. But it depends on your own game system. Just remember to remove the health on the server and not on the clients, since its a replicated variable. You can read all about it here: https://docs.unrealengine.com/en-US/Resources/ContentExamples/Networking/index.html

avatar image David432 Jun 13 '19 at 07:08 PM

something like this? https://imgur.com/a/jBnrXu0 (btw this doesn't work, I'd just like to know if I'm on the right way)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question