Syncing bullets

Options
I am trying to find the best prediction method for fast moving bullets. The closest I have to what I want is bullets which instantiate normally and the start position & rotation is just handled with an RPC and I do an "AllViaServer". I let each client handle the movement...but the problem comes when I move around and bullets appear from mid air. If I do "All" the my bullet if going much faster than the other bullets because it has a head start on movement.

What is the best way to handle fast projectiles? I have slow ones which work perfectly but my game has bot fast and slow projectiles.

Any help will be greatly appreciated!
Russell

Comments

  • How fast of bullets are we talking?

    Could you not use a raycast and not actually instantiate an object?

    Regardless, from what I gather from your message, it almost sounds like your bullets are losing velocity over time, which makes me think you're powering it by "AddForce", I would put a script on each bullet, and move the position directly.
  • vadim
    Options
    You never need sync bullets.
    Send shooting event (to add some visual) and shooting result event (hit detected on shooting client)
  • Betazero
    Options
    The only thing I sync is the start position and I let the clients handle it after that and rpc at death.

    The bullets are like asteroids speed. Not too fast but fast enough to cause some issues.

    How do I move the bullet without addforce to make it look the same as using addforce? I think this could help a lot but I am not sure how to do it. I imagine I use time and adjust its position ?
  • vadim
    Options
    You can make bullets move same paths on all clients if calculate their positions with same function based on PhotonNetwork.time and initial conditions as start point and velocity. Simplest is linear function: pos = startPos + velocity*(PhotonNetwork.time - startTime)
    Because of lag (round trip time > 0), bullets from other clients will spawn not exactly at same point as on shooting client but with offset about velocity*rtt. If this is problem, you can try lerp between that path and another, calculated from shooter visible start point.