Shooting Arrows and turning off Photon Transform View ( or what is best practice )

Options
Hello!

I am using PhotonNetwork.Instantiate to spawn an Arrow attached to a bow. I have a Photon View with a Photon Transform View so the remote players can see the Arrow and which way it's pointing.

Upon Arrow release, I was thinking about turning off the Synchronize Position and Synchronize Rotation since the Arrow has a force applied to it, it's going to travel the same vector on all remotes.

Is that the best solution? I played around with Interpolate Option and Teleport if distance greater than x but since it travels so fast, that's what I came up with for now.

Can you even turn off the Photon Transform View during runtime? I know in the editor it says no.

Thanks!

Comments

  • Hi @matrix211v2,

    if you are using PUN 2, I would recommend you taking a look at the Asteroids demo. In this demo we are instantiating the bullet by using an RPC without making any use of PhotonNetwork.Instantiate. As a result the instantiated game object doesn't need an attached PhotonView component and we don't apply any further synchronization besides the initial setup on all clients.

    If you want to take a closer look at this solution, you can open the Spaceship class from the demo and take a look at the Fire function.

    A similar solution will work in PUN Classic, too.
  • matrix211v2
    edited December 2018
    Options
    @Christian_Simon

    That sounds like what I am looking for. Not sure how that going to work with an Arrow that remote players will need to see "before" it's released / fired. I can see how, in an Asteroids game, that you can instantiate using an RPC since it just comes into existence and moves a direction.

    I guess I could PhotonNetwork.Instantiate the Arrow for the remotes to see, and when it's fired, destroy the Arrow and use a RPC to create the new Arrow like the bullets in the Asteroids demo.

    I will look into the Asteroids Demo and let you know.
  • I see. In this case the best solution might be, to use PhotonNetwork.Instantiate to instantiate the object without any synchronization options. Then either use the InstantiationData or an RPC to parent the instantiated object under a certain bow game object. This way the arrow will 'move' with the bow and you don't have to synchronize the arrow directly (it happens through the bow which - I guess - is part of the player object and synchronized this way somehow). To fire the arrow, you can use another RPC - this would be similar to the Asteroids demo. Some time after firing the arrow, the Owner of the object has to destroy it by using PhotonNetwork.Destroy.
  • @Christian_Simon

    I think I'm going to go with having the Arrow already on the bow and use RPC calls to turn on / off the mesh and still have it sync. When the Arrow is released, then use the RPC calls based on the Asteroid demo to create the Arrow for all to see.