playMaker

Author Topic: PhotonNetwork.InstantiateSceneObject  (Read 23572 times)

flu2120

  • Playmaker Newbie
  • *
  • Posts: 12
PhotonNetwork.InstantiateSceneObject
« on: November 13, 2013, 06:16:23 PM »
Hello,

Is there an action associated with network instantiate scene object in playmaker, or are we to only use photon network instantiate?

 I am trying to create one game object when the scene loads, however with photon network instantiate, the object seems to spawn each time a player connects (This could also be because of my incorrect logic).

Regards,

Simon

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: PhotonNetwork.InstantiateSceneObject
« Reply #1 on: November 14, 2013, 12:40:57 AM »
Hi,

 It's perfectly valid to have a scene object set with a photonView, it will be present and dealt with normally by all running instances loading that scene. However if you want to do this, can you explain your use case? it's a very unusual ( but valid in some cases) way of dealing with scenes.

In your case, this is a logic issue. What happens I guess is that everytime a user enters this scene it instance again that object. What you want is first check that this object is not present and already instanciated, THEN you can create it if necessary.

 Does that make sense?

bye,

 Jean

flu2120

  • Playmaker Newbie
  • *
  • Posts: 12
Re: PhotonNetwork.InstantiateSceneObject
« Reply #2 on: November 14, 2013, 06:54:55 AM »
Hi Jean,

Thank you for the reply.

What I am trying to do is instantiate a spawn point once a game is created, then move the spawn point when there are two players in the room. I instantise the object, along with the player in the game manager.

Unfortunately, even though the spawn point object moves in the second players game (has mesh renderer so i can see it), the x,y,z values of its spawn point don't change and it spawns where the first player spawned.

I think I am having a similar problem with the post:
Re: Photon Instantiate-object spawn point being ignored?[SOLVED]
However, I am not experienced enough to understand the answer.


I hope this makes sense. I have been working on this problem for so long now, I am not even sure where I am at. Tried so many ways and only seem to be getting more stuck.

Regards,

Simon

flu2120

  • Playmaker Newbie
  • *
  • Posts: 12
Re: PhotonNetwork.InstantiateSceneObject
« Reply #3 on: November 14, 2013, 05:00:00 PM »
I believe I may have found my problem and it had to do with how I was using global variables.

Tell me if I have this right.

With any object that needs to look at a global variable, do they need to have a photon view script attached?


Regards,

Simon

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: PhotonNetwork.InstantiateSceneObject
« Reply #4 on: November 15, 2013, 06:01:45 AM »
Hi,

 Exactly.

Also, you are aware that I exposed the room and player properties to PlayMaker now right? you can set properties for a room or a player that can be accessed from any where, that may be a good and clean alternative to what you are trying to achieve.

bye,

 Jean

flu2120

  • Playmaker Newbie
  • *
  • Posts: 12
Re: PhotonNetwork.InstantiateSceneObject
« Reply #5 on: November 15, 2013, 06:44:26 AM »
Hello,

Room and player properties? No, I had no idea, but this sounds very useful! Can you please point me in the right direction so I may read up on this. Didn't see it mentioned in the Photon demo documentation.

Also, would this help with instantiating objects I want to have in the scene straight away? Eg 10 barrels with physics in a room. Because at the moment, it seems I have to instantiate each object individually from my assets to the hierarchy in order for them to instaniate correctly. This would be a pain if I wanted to place items in particular places.

Regards,

Simon

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: PhotonNetwork.InstantiateSceneObject
« Reply #6 on: November 15, 2013, 06:53:20 AM »
Hi,

 You should be able to have your barrels as part of the scene, what's not working when you do that?

 -- room properties are exposed in the Photon Documentation pdf in the photon folder in your assets ("PhotonNetwork-Documentation.pdf"). And you have a series of custom actions that goes with it like:

PhotonNetworkCreateRoomAdvanced
PhotonNetworkSetRoomCustomProperty
PhotonNetworkGetRoomProperties
PhotonNetworkGetNextRoomProperties

Together with global events feedback when a room property is changed.

PHOTON / CUSTOM ROOM PROPERTIES CHANGED

 Use this event to scan the room properties for what changed ( when another instanced edited the room properties)

Bye,

 Jean

Bjakuja

  • Junior Playmaker
  • **
  • Posts: 75
Re: PhotonNetwork.InstantiateSceneObject
« Reply #7 on: January 30, 2014, 04:44:51 PM »
Hi! I have one request related to this post, I need that action that will instantiate objects on scene through network. Here is my problem in short:

When players are in game I want to create game objects periodically over time, for example I want some med packs, ammo, weapon... and when they are created they remain there until players pick them so I have some system that will check is game object null (create object) or not (don't create) and with random cooldown to check those items but problem occurs when master client leaves room, all items that are created by master client are destroyed immediately which is very bad, I want items to stay on scene after master client is switched so for that I need action that will actually create items directly on scene and other one that will remove from scene. I tried to create something using  PhotonNetwork.InstantiateSceneObject but failed unfortunately so Jean or anybody can you help with this issue?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: PhotonNetwork.InstantiateSceneObject
« Reply #8 on: January 31, 2014, 06:38:49 AM »
Hi,

 indeed, good question!

you should not have these objects as networked, but simply created on each scenes as regular objects. you can do that by sending an event to everyone, and everyone will manually create that object. Build a Manager that exists on each scene ( not networked neither) for that that sole purpose is to do this.

Does that make sense? as one of your player picks up one of these items, it will fire an event "PICKED UP" to everyone and the managers will responds by deleting that picked object manually too.

bye,

 Jean

Bjakuja

  • Junior Playmaker
  • **
  • Posts: 75
Re: PhotonNetwork.InstantiateSceneObject
« Reply #9 on: January 31, 2014, 11:12:27 AM »
Hi Jean, well good solution i will try it later but i think i will have some problems with this since items are created on each scene so what if player leaves pick all items and leave game, then he reconnect and items will be spawned from start, i can't actually check what items are on each scene and what items to create and what to skip, for this i would like action that create items on scene visible by others, destroyable by others using on scene functions. So for that solution i can create manager as you said that wait for cooldown from master client, when time comes i send to each manager to create certain items, that make sense but how to check what items are created, what items to be created and what to be not?
Kind of difficult how to control items on scene in multiplayer.

I saw some function on some pages that uses this PhotonNetwork.InstantiateSceneObject and it turns out that object will belong only to scene and it has to be destroyed in same way, are you familiar with this Jean?

Speaking of this i have another question, using those get/set position, rotation for each character in order to synch variables depends on view is mine or not and plus mecanim animations synching input and other stuff, that will create mess on scene if there is over 10 - 15 people i guess, that would be too heavy to render without lag resulting huge bandwidth?
So my question is this:
Should i use photon networking if i want in my game for example 100 players on same map? Or this is only for small games room based? Cause i see that RPC message limit is only 500 on photon cloud>? 

We will invest in servers ofc if game gets on popularity, but still want some expert opinion ;)

Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: PhotonNetwork.InstantiateSceneObject
« Reply #10 on: February 03, 2014, 05:12:34 AM »
eh eh, cause you don't know you can store custom properties per room :)

https://hutonggames.fogbugz.com/default.asp?W1114
https://hutonggames.fogbugz.com/default.asp?W1115

and there is a related global event called "CUSTOM ROOM PROPERTIES CHANGED", but I don't think you need that one in your case, well, it could be your way to have everyone else refreshing for a particular pick.


 Simply store that kind of info in the room properties and done, any instance can manage them items.


 the other obvious choice is to have a proper database back end. you can't really expect the multi player system to handle everything, at some point ( and in 99% of the games), a proper database is required to handle all these case gracefully)

bye,

 Jean

Bjakuja

  • Junior Playmaker
  • **
  • Posts: 75
Re: PhotonNetwork.InstantiateSceneObject
« Reply #11 on: February 05, 2014, 08:38:06 AM »
Thanks Jean, I will try this suggestion of yours with items, i understand concept of creating items on scene, so items will be created in each scene and i have to store them into room properties using keys and when they are destroyed i have to set that remove from room properties and it will trigger event on room properties change and then i send rpc to each scene to remove certain item, right?

Tell me one more thing, can i check those items and room properties for new players that join room? For example player join room, on start i use action get next room properties and get them all, check each and if not found i have to destroy item on scene for that player or something like that?

Thanks again Jean!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: PhotonNetwork.InstantiateSceneObject
« Reply #12 on: February 06, 2014, 05:03:19 AM »
Hi,

 of course, you can get or scan room properties whenever you want, not just when one of its property got updated,

bye,

 Jean

600

  • Beta Group
  • Hero Member
  • *
  • Posts: 713
    • Flashing Lights
Re: PhotonNetwork.InstantiateSceneObject
« Reply #13 on: July 16, 2014, 05:08:00 PM »
Hello,

Where could I find this action?
PhotonNetwork.InstantiateSceneObject

Looked in PM Wiki and Ecosystem.

Is it a good idea to use it on human AI ?
A scene manager would deal with AI spawning depending players positions.


Thank you!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: PhotonNetwork.InstantiateSceneObject
« Reply #14 on: July 21, 2014, 07:33:53 AM »
Hi,

 ok, please find the action. It's not tested so let me know how it goes.

 I don't know what you mean by AI here? network systems and AI are different topics. Can you precise?

 If it's just for player spawing position, I am not sure if you mean that you want the SceneObject to handle this or if it's a general questions. Typically, you have everything as is for Photon network. For AI, PlayMaker will be perfect basically :)


 Bye,

 Jean
« Last Edit: July 21, 2014, 08:24:03 AM by jeanfabre »