I share whit you the method for using Destroyit whit MFPS !
From Zangad on Destroyit forum https://forum.unity.com/threads/release ... 22/page-10
Here is a step-by-step guide to using DestroyIt with MFPS 2.0 for multiplayer destruction.
(1) Import MFPS 2.0 Multiplayer FPS
(2) Open the \MFPS\Scenes\ExampleLevel scene
(3) Import Photon PUN 2 (Free)
(4) Login to Photon Cloud, setup a new Photon PUN project, and copy the AppId into the PUN Wizard
(5) Import DestroyIt
(6) From the top menu, choose Window => DestroyIt => Setup - Minimal
(7) From the \DestroyIt\Demos (safe to delete)\Prefabs\Destructible Objects\Pristine folder, drag the Column prefab into the ExampleLevel scene
(8) Select the Column game object in the Hierarchy and choose Add Component => Photon View
(9) Drag the Column game object to the Observed Components field, and check the Synchronize Position and Rotation checkboxes on the Photon Transform View component
(10) Open the \DestroyIt\Scripts\Behaviors\Destructible.cs script and add the [Photon.Pun.PunRPC] attribute to the ApplyDamage method
Destructible.cs
(11) Open the \MFPS\Scripts\Weapon\bl_Bullet.cs script and add the section of code below to the OnHit method
Code (CSharp):
Code: Select all
DestroyIt.Destructible destObj = hit.collider.gameObject.GetComponentInParent<DestroyIt.Destructible>();
if (destObj != null)
{
PhotonView pv = destObj.GetComponent<PhotonView>();
pv.RPC("ApplyDamage", RpcTarget.All, damage);
}
(12) Save all your changes to the scripts and the ExampleLevel scene
Note: The instructions provided below are if you want to test multiplayer destruction in your scene with another developer. Each developer on your team will need MFPS 2.0 and DestroyIt and have them imported into the project as outlined in steps 1-5 above.
(13) Export your changes into an asset package. Use CTRL-click to select the ExampleLevel scene and the two scripts you modified, right-click and choose Export Package. Uncheck Include Dependencies so only the modified files are included.
(14) Have your developer friend delete his/her ExampleLevel scene, and import your package so you are both running the same code.
(15) Run the scene, and have your friend also run the scene on their computer. Note that they will also need to use the same Photon AppId as you.
(16) From the in-game menu, create a new server and Join. Your friend should join the other side. Now when either of you damage or destroy the destructible column with a bullet, you will each see progressive damage and the particle effect.
From here, you could expand your damage checking to knife cuts or grenades/molotov cocktails, so those also damage DestroyIt destructible objects. You could also try using a more advanced destructible object, one that has damage effects like smoke or sparks, or one that leaves persistent debris from a destroyed prefab. In the case of persistent debris, you might want to make the debris pieces observable to Photon by adding Photon View components to each of them and syncing the position/rotation. Or you might decide that you like persistent debris but don't want to worry about syncing each piece with all clients, to save network traffic. It really depends on if the position of each piece of debris is important to track in you game or not. If flying debris can damage players, block movement (ie, a cave collapse), or provide cover, then you probably want to track its position/rotation for all clients.
///////////////////////////////////////////////////////////////////////////
And for reloading the object destroyed on the reload of the scene you need this one :
///////////////////////////////////////////////////////////////////////////
What is used to reset the scene is bl_RoomSettings.ResetRoom(). The way it is setup, though, it only resets player and score data for PUN - it doesn't actually reload the scene. That's why the destructible objects are never reset. Not reloading the scene means your levels can only ever have static (non-modifiable) objects in them. Optionally, you could programmatically add the objects to your scene, but that would be fairly tedious and require more programming.
However, I found a place where you can reload the scene that seems to work: right before resetting the room. Now, I don't know if this is the preferred method for resetting a level in MFPS, but I'll share my changes in the hopes that it will at least get you past where you're stuck.
NOTE: I would advise contacting Lovatto Studio and asking them what is the best way to reload a dynamic (non-static) scene with MFPS 2.0. Be sure to mention that you are removing objects from the scene and need to reload the scene after a match in order to reset everything. They should be able to tell you the best way to do that for their asset.
Having said that, here's what worked for me:
1) Open the bl_RoundTime.cs script. Paste this using statement at the top:
Code (CSharp):
Code: Select all
using UnityEngine.SceneManagement;
Code (CSharp):
Code: Select all
if (RoomSettings)
{
RoomSettings.ResetRoom();
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
Note : You have pictures and video on the original post will help you to integrate it
https://forum.unity.com/threads/release ... 22/page-10
Enjoy