playMaker

Author Topic: Photon - Enemies "moving towards" player targets - position sync issue  (Read 2323 times)

kavery

  • Full Member
  • ***
  • Posts: 149
First, I can't thank you enough for the hard work on the photon PM features. Never thought I'd be able to network MP.

Right now in my game I have everything working over the network except for the walking path of the enemies. They are programmed to use local logic to find the closest player target by tag, then a "move towards" said target. Each player has 6 invisible location zones placed around the base (the targets). This sort of works in MP but it's not reliable enough to maintain owner and slave instance locations. I'd like to maybe just control the movement/position of the slave using owner RPC commands, but syncing the position on every frame is jerky. Wondering how else one could approach this.

Other thoughts: I could pass G.Object variables (or array index) of the player targets from owner to slave via room properties - to help ensure accuracy of the target (one of the problems is - found closest targets don't always match), but it still wouldn't be perfect and is rather involved. Syncing position at intervals would help accuracy but would result in harsh snap movements.

I've thought about sending a vector 3 of the owner's target on every frame for the slave to follow, but this seems inefficient? I still think avoiding the local logic for slave movements would be cleaner.

*No physics involved.

Any ideas would be greatly appreciated!
« Last Edit: June 29, 2016, 01:45:58 PM by kavery »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi,

 use the MasterClient for sure, and SceneObjects, then the enemies are owned by the room itself, and controlled by the masterClient, as for smoothing, more lerp will help and also increase sending rate, or actually decreasing rate and put more lerping. you'll have to fiddle around to find what works best for your case for smoothness.

Bye,

 Jean

kavery

  • Full Member
  • ***
  • Posts: 149
Thanks that helps. For the 'move towards' target location I decided to pass a synced Vector3 of the host's target on every frame for the others to move towards. Then on intervals like stop walking, attacks or getting hit/knocked down, I get location of host once and set location once to ensure sync. It's working really well. I get occasional snaps to location so maybe I should do some lerp to smooth out the kinks. But maybe not even needed. I'll see when I have 20 guys all moving around.