playMaker

Author Topic: Photon Instantiate-object spawn point being ignored?[SOLVED]  (Read 7880 times)

Swift_Illusion

  • Playmaker Newbie
  • *
  • Posts: 41
    • Midnight Tinkering
Photon Instantiate-object spawn point being ignored?[SOLVED]
« on: October 02, 2013, 03:05:24 PM »
Hello,
I've been trying various methods to try and solve this but in the end I believe the only problem left that could cause my issue is playmaker itself, possibly a bug, or maybe something I've missed?.

I'm instantiating multiple objects that have their position/rotation adjusted from the location of a specified object. It shows up in the right position in the window I'm creating the objects from, but in all the other players windows, the objects are created relative to the center of the world (0,0,0).
So it seems to be ignoring the base position/object spawn point it is meant to be adjusting from, and just starts from 0,0,0 in other players windows.

(I do have all the photon view/object proxy, etc scripts setup correctly)
« Last Edit: October 10, 2013, 02:59:46 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon Instantiate-object spawn point being ignored?
« Reply #1 on: October 03, 2013, 02:12:11 AM »
Hi,

 your prefab may not actually synchronizte the transform. how did you set up the photonView component? what's its target?

bye.

Jean

Swift_Illusion

  • Playmaker Newbie
  • *
  • Posts: 41
    • Midnight Tinkering
Re: Photon Instantiate-object spawn point being ignored?
« Reply #2 on: October 03, 2013, 10:05:01 AM »
Thanks a lot for the response.

Here's the photon view, the target is the prefab object/itself.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon Instantiate-object spawn point being ignored?
« Reply #3 on: October 04, 2013, 02:02:25 AM »
Hi,

 ok, and can you double check that no fsm or script is actually setting the position of that gameobject to 0,0,0?

 Bye,

 Jean

Swift_Illusion

  • Playmaker Newbie
  • *
  • Posts: 41
    • Midnight Tinkering
Re: Photon Instantiate-object spawn point being ignored?
« Reply #4 on: October 04, 2013, 02:35:56 AM »
Here's the action that creates that object.

In the window that this FSM runs, the object is built in the correct position, relative to the "BuildingGenerator" object.
However in all the other windows it is instantiated in, it is built relative to (0,0,0).
It still correctly accounts for the "CitgyGen_HeightGrowth" and "CityGen_RotationV" offset in the other windows, but ignores the object Spawn Points influence.

Swift_Illusion

  • Playmaker Newbie
  • *
  • Posts: 41
    • Midnight Tinkering
Re: Photon Instantiate-object spawn point being ignored?
« Reply #5 on: October 06, 2013, 10:28:36 PM »
The results of some more testing.
I tried instantiating the actual object holding the building generation FSM (which was also the object I had specified as the original spawn point for the pieces), wondering if it might not have instantiated the position correctly because the object its spawn point was referring to didn't exist.
Regrettably that didn't fix it either.
Below is a screenshot of the FSM in a players window (where the building isn't being instantiated correctly).

So it does know where the spawn object is, but it still won't spawn objects relative to that.

A second test, I tried to just get the position of the spawn object, and add the resulting Vector3 to the offset Vector3, and used the resulting vector as the spawn position (so the 'Spawn Point' was left empty),
however it STILL seemed to ignore the spawn objects position as if it got it at 0,0,0, even though while debugging the player scenes the building generator is spawned at the correct location, so the building pieces shouldn't be getting created relative to the center of the world.

I seriously don't have a clue what else I can try here, I'd greatly appreciate any help I can get with this.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon Instantiate-object spawn point being ignored?
« Reply #6 on: October 07, 2013, 03:03:29 AM »
Hi.

 What do you mean "relative to that"? do you expect the prefab position to be taken inconsideration? the prefab will be taken with a clean transform, the spawn point will be the transform applied to the prefab instanciated.

am I understanding correctly what you want to achieve?

bye,

 Jean

Swift_Illusion

  • Playmaker Newbie
  • *
  • Posts: 41
    • Midnight Tinkering
Re: Photon Instantiate-object spawn point being ignored?
« Reply #7 on: October 07, 2013, 08:29:01 AM »
I have an I have an object, called "TOOL_BuildingGenerator_Group1".
On that object is an FSM, which is instantiating pieces of a building relative to it,
as shown here where "TOOL_BuildingGenerator_Group1" is specified as the spawn point.

The building has a random amount of floors, so each time it runs through all the pieces of one floor, it adds a Y value to the "CityGen_HeightGrowth" vector 3 variable, which acts as an offset from the location of "TOOL_BuildingGenerator_Group1", and builds the next floor "Y value" higher.
Once it has finished, "TOOL_BuildingGenerator_Group1" will be moved in a certain direction and begin generating the building at that location.
This way I can randomly generate streets of buildings (which I require for my project).

This all worked perfectly fine, until I started trying to instantiate the building pieces across a server.
In the host where the building generation FSM runs, it works fine. But when I open another window as a player and join that room, no matter what I try, it ignores the X/Z offset "TOOL_BuildingGenerator_Group1" should be giving it as the chosen spawnpoint object, and the building shows up at 0,0,0.
As the tests in my previous post shows I've even instantiated "TOOL_BuildingGenerator_Group1", and gotten its position as a vector 3 variable and manually added it to some of the pieces as a test, but it still gets ignored.
The photon view of the object is the prefab itself selected


I really don't know where to go from here or what else I can test or if it's something I'm missing or a bug but I feel if it's a bug this is something that should seriously be working as I already know a lot of situations in my projects where creating an object from a spawnpoint will be required.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon Instantiate-object spawn point being ignored?
« Reply #8 on: October 07, 2013, 09:07:52 AM »
Hi,

 I'll run some proper test tomorow, I have planned on spending some time to upgrade Photon, so I'll have a close look at this.

bye,

 Jean

Swift_Illusion

  • Playmaker Newbie
  • *
  • Posts: 41
    • Midnight Tinkering
Re: Photon Instantiate-object spawn point being ignored?
« Reply #9 on: October 07, 2013, 11:23:43 AM »
Thank you so very much for that, I greatly appreciate it!
Goodluck with the testing :)!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon Instantiate-object spawn point being ignored?
« Reply #10 on: October 09, 2013, 02:06:44 AM »
Hi,

 Ok, I confirm that it totally works here. I am pretty sure you have a conflict, like another fsm is actually changing the position of your newly instantiated object. OR the values you inject in the actions are not the one you think at the time of call.

Bye,

 Jean

Swift_Illusion

  • Playmaker Newbie
  • *
  • Posts: 41
    • Midnight Tinkering
Re: Photon Instantiate-object spawn point being ignored?
« Reply #11 on: October 10, 2013, 01:23:30 AM »
Thank you so much for taking the time to test it.
I was 100% sure it wasn't anything to do with conflicts so after some more head scratching trying to workout how it would work for you, I discovered the solution.

You need to use NetworkView for the object to instantiate correctly. I had imagined with it using the Photon Network that PhotonView was what you needed but that wasn't the case, at least as far as instantiating goes.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Photon Instantiate-object spawn point being ignored?
« Reply #12 on: October 10, 2013, 02:59:23 AM »
Hi,

 yes, instantiating within Photon, only works on photonView.

 I am glad you found it!

bye,

 Jean