I am fairly new to unreal, and I am in the process of creating a game, similar to that of the Counter Strike Source mod, Smash. Here is a gameplay video to show what I am talking about:
I have achieved everything I am required, physics objects, a projectile spawner that will shoot boulders upwards at a random horizontal velocity and fixed vertical velocity, third person template converted to first person with sprinting and such.
However, I am unable to figiure out how to replicate the physics of the boulder, and to replicate all the physics objects (platforms and such). How can I go about this?
Thanks in advance
There is no simple method for this. Replicating physics will not work ever for gameplay.
With physics thing is that even 1ms delay in when event started results in different outcome.
For eg that second player running and failing, if he was there 1ms earlier he would rotate platform in different direction, thus falling somewhere else.
With lots of code (you go here against what unreal assumes) you probably can cheat the system.
- create all physic objects server side only.
- create replicated copies of server object, do replication in your code (ie. get location and rotation of object).
- server should read on tick rotation and location of physics object then replicate it to client.
- on clients you disable physics objects, and put their non physics replicated copies in same spots, then apply rotation and location.
So first make 2 boxes, one red one blue.
Place red box on server. make server send (replicate that box transformation) to clients.
Then make clients replace red box with their blue replicated copies.
Best for this would be first person template it has those physics boxes you can shoot.
If you cannot make that hiding and switching boxes then you will not create rest.
I tried several times to go against what unreal wants and every time i did it, in another place some other problem surfaced caused by my unusual implementation of first thing.
So be prepared for pain down the road. And better make whole physics part of gameplay before you go further.
Nothing has changed. They still have no plans to do physics replication. Its something that is complicated with how UE4 is setup.
I think it will be never done… you can replicate few bouncing projectiles… but replicating fot example destructible mesh with 200 chunks … its like DDOS…
For what you need to replicate physics?
I wanted to have in my game physical destructible chunks with collision… but i ended with no collision chunks and its fine…
The trick is not replicating physics, its getting it to sync nicely on the client.
This requires some form of physics prediction.