playMaker

Author Topic: Photon Bullets - Best practice  (Read 2264 times)

adrian

  • Junior Playmaker
  • **
  • Posts: 52
Photon Bullets - Best practice
« on: March 06, 2015, 09:23:47 AM »
Hi,

I've followed the Photon demo tutorial and have my desired players and map all up and running. I am using the simple bullet/health system from the top down shooter tutorial. How do I properly deal with bullets? I understand the idea of photon instancing but am unsure how to set the bullets to properly register collision and send the "Missile hit" to other players. Can anyone help/suggest a tutorial?

(I have photon view and object on the bullets)

Thank you

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon Bullets - Best practice
« Reply #1 on: March 09, 2015, 03:21:36 AM »
Hi,

 a buller is tricky to implement in a network environment, especially if it uses physics and if it goes fast.

 if you are using physics and it goes fast, the bullet should only be simulated when you are on the owner and all other slaved instance simply slaved ( without any active trigger or colliders), only the owner is responsible for collisition or trigger detection. This is because each running application will be slightly delayed due to network latency, and so the collision will be different on each.

Bullets should be knowing the end result before it's even fired, that is do a raycast of where the bullet will end up and it it hits a player then the bullet animation is a secondary animation, every instance will know the results regardless of how the bullet is animated or simulated, this is the preffered way for 99% of the bullets.

 not if you are simulating a rocket or inter continental type of waepon, then yes you can use proper physics and wait for collision, but again on one instance only to avoid different results on each running application.

Bye,

 Jean

adrian

  • Junior Playmaker
  • **
  • Posts: 52
Re: Photon Bullets - Best practice
« Reply #2 on: March 09, 2015, 07:50:04 AM »
Hi Jean,

That is so helpful, thank you. I have it all up and running as an instance using ownership to decide if it registers collision or not, then RPCing to player. All works great, sadly when I try to Raycast it does not work yet but I have a thread on bugs that will hopefully get to the bottom of it. Thank you again for the help.