playMaker

Author Topic: Help with random objects / variables / network [SOLVED]  (Read 2378 times)

jess84

  • Hero Member
  • *****
  • Posts: 515
Help with random objects / variables / network [SOLVED]
« on: October 02, 2013, 12:35:25 PM »
Hi,

I'm having a lot of trouble with random objects...

I used Select Random Game Object to choose from 3 of my gameobject prefabs, and chose to save the result as a variable. I then want to show that gameobject to players who are clients.

Because the S-R-G-O action is being run by the server player, that variable isn't being shown to the clients.

I've tried using Photon Network Instantiate to create the object for al players, but nothing happens. I've also tried running Events broadcast to all players to create this object, but nothing happens.

I seem to only be able to spawn a gameobject based on this variable on the player who ran the original action.

Any ideas? I've spent the past day playing around with methods that should in theory work. (like running an Event to then run on all players, getting the original stored variable, and then setting another variable - and using that. but no success.)

 :'(
« Last Edit: October 03, 2013, 03:43:34 PM by jess84 »

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Help with random objects / variables / network
« Reply #1 on: October 02, 2013, 01:02:06 PM »
I should add;

I have no problem performing this creation with a regular gameobject prefab that I've specifically selected.... it's just when getting a variable containing the random object given.

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Help with random objects / variables / network
« Reply #2 on: October 02, 2013, 02:29:45 PM »
Is there a reason why global GameObject variables have the 'network sync' disabled? This doesn't make much sense to a noob like me.... surely it should be no different to how a bool or float is handled (which have the option to network sync).

I think I'm completely out of ideas now. I've converted a local FSM variable to a global gameobject variable, and I can step through and see it's holding the correct info when playing, but I still have no idea how to communicate that to other players.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Help with random objects / variables / network
« Reply #3 on: October 03, 2013, 02:22:12 AM »
Hi,

 choosing the random object and spawning is fine in your case. What you are missing is  how to communicate to others ( I am rewording so that you can validate that I understand correctly).

 for this, you need to fire an event from the instance that is spawned by Photon. You can know that by checking with the action "is mine", if the answer is false, then it means you are running on a other application instance, and thus you need to fire a gobal event in that environment for others gameobjects to be aware of this new comer.

does that make sense?

You can also study firing RPC events, like the chat systems. have you studied the chat system?

bye,

 Jean

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Help with random objects / variables / network
« Reply #4 on: October 03, 2013, 02:17:30 PM »
Not really.  What information am I firing from the instance?

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Help with random objects / variables / network
« Reply #5 on: October 03, 2013, 03:43:04 PM »
No worries, it's now sorted.

P1 creates gameobject based on local fsm variable.
This event sends an event to create the same object on clients and deletes itself.

Quite an annoying way of doing it though.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Help with random objects / variables / network [SOLVED]
« Reply #6 on: October 04, 2013, 01:25:07 AM »
Hi,

 I am not sure there is another way if you want network synching with gameobjects.

bye,

 Jean