Syncing shooting

Sorry for the stupid question but I have a bullet that is fired every 0.25 seconds. How would this be synced in Fusion?

  IEnumerator _Fire()
  {    

while (true)
    {
      Fire();
      yield return new WaitForSeconds(0.25f);
    }

  }


Answers

  • Tbh I don't really know what's going on here but I think you're trying to do an RPC function. You want to sync this across all clients im assuming. Let me know if I'm totally off here or it helped...


    [PunRPC] //Make sure you add this to identify it as an RPC function

    void FireWeapon()

    {

    //Fire gun or whatever your function is

    }

    //We'll use this function to execute the RPC function for all clients

    public void Fire()

    {

    //Here we're calling the RPC function we just defined above.

    GetComponent<PhotonView>().RPC("FireWeapon", RpcTarget.All);

    }

  • Hi,

    Thanks for your reply.

    This would work in PUN however I'm trying to do this in Fusion where I'd need the weapon to fire every X ticks on the same tick for every player. Hope that makes sense.

  • Hi @Jaynesh ,


    Take a look at the TickTimer class included on Photon Fusion.

    You can read more about it using our search bar: https://doc.photonengine.com/en-us/search?p=fusion&v=current&addsearch=ticktimer

    This is a tick accurate timer that you can use during the simulation to calculate timed delays, so you can just check if the cooldown is over and fire again, for example.


    --

    Ramon Melo

    Photon Fusion Team