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"

Is it possible to have object movable by many players?

My question is pretty straight forward. I want to have an object that will be moved for all players when one of them presses key on keyboard (like F or somehing). I've tried many ways but the result is mostly that when server presses F object normaly moves for both, server and client. But when client presses F it only moves for him, not for server. And when server presses F again, from client side it looks like the object just teleported to its position on server side. So is it possible to achive something like this? To have one object controlled by multiple players?

Product Version: UE 4.15
more ▼

asked Mar 30 '17 at 03:03 PM in Blueprint Scripting

avatar image

10 1 5 8

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

1 answer: sort voted first

The actor is owned by the server, so to move actor from client you need to ask the server to move the actor. Client can't directly move the actor because it is on the server side. To achieve this you need to have a custom event on the server that's set to run on server, and then you can call this event from the client and ask the server to move actor. But you can only do this from blueprint class that is replicated between client and server. You can't call for GameMode and try to execute custom event, because GameMode exists on server only. alt text

net.png (107.5 kB)
more ▼

answered Mar 30 '17 at 04:39 PM

avatar image

206 5 14 16

avatar image kuboxus Mar 30 '17 at 05:34 PM

I know about events happening on server and I did those. The thing is that I'm not able to achive the same movement on server and client. It looks like it's replicating from server to client but not the other way. I've tried making custom events but maybe I'm doing something wrong 'cause I'm stuck and have no ideas how to accomplish my goal. If you would be so kind, can you maybe try doing it yourself and see if you can find a way to move the same object in real time from server and from many clients?

avatar image PlainBane Mar 30 '17 at 06:32 PM

Ok, I made a little sample project for you. In the project go to FirstPersonBP/Blueprints and open FirstPersonCharacter. Inside of it you will have three numbered commented parts , that's the logics for server client functionality. To test it press play and shoot yellow ball and you should be able to see the ball shoot from server and client views. Oh I forgot to untick Run Dedicated Server under play options if you want to see server view please disable that check box.

Google Drive download link

avatar image kuboxus Mar 30 '17 at 07:37 PM

Ok, I understand it very well now. But there's one more thing. I know how to spawn actor and other things, but I really can't find a way to get actor reference from a level into FirstPersonBP. I have to have this reference to be able to move this actor. I tried this and I am just getting an error: alt text alt text So, how to get level object reference into another BP, or maybe there's better way to do it?

avatar image PlainBane Mar 30 '17 at 08:01 PM

Take a look at this Forum post in 8th post from the top, you can see how to make a line trace from player character camera. You can use this to get the reference of the actor you are looking at and then you can send the reference to server so it can move the selected actor. I don't really know any other way to get reference from level in blueprints. In c++ there are options, but blueprints are a bit limited unless you use Level Blueprint. You could get the reference from level in level blueprint and then pass it to the character. Like this

alt text

level.png (136.9 kB)
avatar image kuboxus Mar 30 '17 at 08:32 PM

I've tried both of these methods and I'm getting those errors: (first one is for method on your screenshot, second for LineTrace) alt text Maybe it's 'cause that I'm using AddActorLocalOffset, maybe I have to use other method to move this actor.

errors.png (16.2 kB)
avatar image PlainBane Mar 30 '17 at 08:59 PM

I added some changes to my sample project. Download this file from GDrive link and close the UE4 Editor, go to sample project NetworkingSample/Content/FirstPersonBP/Blueprints, remove FirstPersonCharacter.uasset and place one from the link in it's place. Launch the editor and press play and aim at the cubes, placed in the level and press shoot and cubes should change location on click. It's a bit buggy, but you can get the idea.

avatar image kuboxus Mar 31 '17 at 02:11 PM

I think that's an answear to my question and this is the easiest way to get this reference. Now that I know this I am able to move the same actor from server and client side in real time. Thanks a lot, I seriously appreciate your help and effort you have put to make my blueprints work.

(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