If I understand your question correctly, you are trying to allow Players to “own” an object so each player in the map can control that object regardless if they spawned it into the world?
What commands are you trying to send to the object in Unity? Could you provide examples, it will help build context.
I’ve been using unity to develop a game, but I’ve run into an issue that is making me consider switching to unreal engine. The problem I’m having on unity is, I can’t have all players on a server send commands for a specific object without assigning and unassigning authority for it every time I want call a command. It of course is possible for me to get that to work, but I’m just wondering if I could get that functionality more easily with unreal engine. So is there a way to easily give all players authority over a non-player object? Any info regarding this is appreciated. Thanks in advance.
Yes. That’s exactly what I need.
I think this is achievable in UE4. I’ll describe it from the perspective of Blueprints, I can’t say much about C++, but it should be virtually the same.
- Your Actor/object should be spawned into the world by the server so it will replicate to all clients.
- In Blueprints you would send an RPC (remote procedure call) from an Actor owned by the client (for example the PlayerController) to the same Actor, but the instance of it that’s on the server.
- The RPC event will execute on the server’s version of the player’s Actor. It’s at this point that your player’s PlayerController can interact with the Actor. Any changes to the Actor that happens on the server will replicate to all clients.
I would highly recommend you to install UE4 and play around with the pre-built starter projects that already have assets and basic game play framework to make sure UE4 meets your design requirements.
They are addforces to a rigidbody.
Here is the code for it
[Command]
void CmdShoot()
{
BallRigidBody.AddForce((PlayerBody.transform.forward) * ShotPowerCurrent, ForceMode.Impulse);
BallRigidBody.AddForce((PlayerBody.transform.up) * ShotHeight, ForceMode.Impulse);
}
This has given me a lot to think about. Thanks a bunch for all the info
Also, this is a great resource to read through about UE4 networking. http://cedric.bnslv.de/Downloads/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf