Unreal Engine VR Controller spawn twice

Hi,

I'm trying to create an Unreal VR Multiplayer Game with Photon. I followed the demo project which was extremely helpful to get a basic understanding of Photon.
https://www.unrealengine.com/marketplace/en-US/product/photon-cloud-api-by-xixgames?sessionInvalidated=true

Instead of the ball, I spawn a VR Pawn, and instead of those boxes when pressing Z, I spawn my VR controller at Begin Play. All movement replication works fine in Multiplayer. Every player can see his own VR controller and all other players VR controller, incl. location and rotation.

But there is one issue: The moment a second player spawns an additional pair of controller spawns for each player.

My VR Controller BP Actor only contains the Photon rep component, Unreals Motion Controller Component with an attached static mesh.

Any ideas?

Comments

  • Hello AronBaron, I have created this blueprint for your case, you don't need a replicator to sync the motion controllers, because it is always owned by each player. A replicator is designed for a detached from the player actor, it is cheaper to use player properties o(r send player data). With this example, you need to add the code to your controller, when you spawn each controller, you will pass the pointer to the photon cloud api blueprint ,and the player number, this way you know who is the owner and you can decide if you need to send or listen for the data. I have made a simple sync of the location and rotation ,you need to do it smoother using a lerp like i do in the replicator or the player position/rotation.
    Here it is the blueprintue:
    https://blueprintue.com/blueprint/7r4c8tt6/
    "lcl" means left controller location
    "lcr" means left controller rotation
    for the right controller, change "lcl" for "rcl" and the same for "lcr" -> "rcr".
  • AronBaronAronBaron
    edited June 15
    Hi Juaxix, that's is pretty impressive! Your code works basically right out of the box. Thanks a lot!!!

    I was just trying another approach by using the Photon Mechanics to update the controller. Would that have been another possible solution?

    I have one more big challenge: I want to replicate a procedural mesh. That's basically the main reason I'm looking into Photon. The host has all the mesh data as arrays (verticals, triangles,...), builds a procedural mesh, and spawns it. The data can be multiple 100MB. How would you handle this?

    I tried Unreals RPC and build a rep-component like the one in Photon, but the chunk size Unreal was able to transfer was too small, so it took forever. If there is a similar limitation for the Photon rep-component I would probably try to send those arrays via Json and build the proc-mesh on the client-side!? After that is done using Photon Mechanics for the location and rotation?!

    What do you think?
  • Yes, the PhotonMechanics interface is a more advanced way to do the same thing, I would say that should be the next step after the BP prototype, you just need to add the interface to your actor and register it and so on.

    For the 100MB data, I wont recommend you to store the data in the server, maybe a crypted url hash to decode in the game and download the data in a parallel thread then process it...but if you want to do it anyway from the photon server, (it will be expensive) i would be splitting it into several chunks paginated in different transactions, you should compress the data first before sending it, as you need to save bandwidth and make sure all the data is sent/received you also need to make sure to use the Reliable flag.

    Dont use JSON to send binary or big arrays. Using a socket should be better, send the data as native is always faster.
  • Ok, got it. That will save me some time.

    Using a socket connection would mean I have to do port forwarding, right? That's what I had to do for Unreal Multiplayer. The second reason I'm looking into Photon is, it does all the magic without Port Forwarding.

    Since Photon has already established a connection between players, is there any way to use that to do a socket connection without manual port forwarding?

    There are basically three ways than:
    1. Socket connection
    2. via Server (Photon or using our server we have for DLC maps)
    3. Share data via Import/Export and dropbox (not very customer friendly)

    A bit more background on the data: The customer will import his own mesh data and bring it into the VR world to look at it with other VR clients. Therefore those data is not like a DLC everyone can download. The client needs to receive those data before he enters the VR world.

  • I did this video to explain how to sync the animation blueprint, it is really simple and straight-forward.


    Yes, using sockets will require to connect to somewhere and send the data, but you can do it over http port (80), it is easier.

  • AronBaronAronBaron
    edited June 17
    Great. I think every tutorial on how to use Photon and Unreal is really helpful due to missing documentation.

    I also finished the VR controller replication by using Photon Mechanics today. It's tested with 3 VR users and works just fine. The Controller could need a bit of stabilization after receiving the data with a lerp like usual. Feel free to use it for more video tutorials. The components are simply Unreals MotionController as root and an attached a static mesh for the controller.
    https://blueprintue.com/blueprint/13olg5pc/

    I like the idea of using the HTTP port. I'm trying to catch up on networking but I'm still at the beginning.

    Could you explain a little bit more about how you would set it up?

    Thanks
  • Yeah, I should do more tutorials, when i get the chance i want to do a snake game tutorial series hehe =)

    There is a problem with your blueprint, dont use the tick for sending the information each frame, that will make a huge amount of messages per second, remember that there is a limit of 500 messages per second per room, so, it is better to use an event with a timer and try to use a time longer than 5 milliseconds, also, dont send data it does not changes either.

    To use the HTTP port you need a web app or service that uses a REST API, take a look to socket.io or any tutorial to control web sockets should be fine too. The idea is ,for example, to have a PHP script that communicates with your photon server and redirect a webhook from photon to your webservice where the actual mesh is, then try to download the mesh directly from that webserver of yours.

    are you cool with that approach? will not significally change your current design. Thanks
  • juaxixjuaxix
    edited June 19
    --duplicated post--
Sign In or Register to comment.