Syncing shooting
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on Fusion.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Syncing shooting
Jaynesh
2021-12-24 09:18:09
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);
}
}
Comments
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
}
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
Back to top