playMaker

Author Topic: Prefab Component Property Retention  (Read 2073 times)

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Prefab Component Property Retention
« on: July 31, 2012, 08:08:48 PM »
Hello,

I am using Get/Set Property actions along with my prefabs, but the prefabs drop their connections whenever they're loaded in a new scene.  Here's an example scenario -

My project has a Player, and a PlayerCamera.  Both of these are created at runtime, and I have playmaker scripts that help them find each other and set their respective details up (variables, properties, FSM events, etc).

On the Player prefab, my initialization script acquires the player Transform, finds the PlayerCamera, and assigns the Transform to the Camera scripts Target property.

My problem is that if I don't have both prefabs in the scene by default, when the Player prefab is created, it loses connection to the PlayerCamera script component.

My project needs to be able to create and destroy the Player at certain points.  Can someone suggest how I can retain this connection between a prefab being created/destroyed, and a Camera system that is persistent in the scene?

Many thanks in advance.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Prefab Component Property Retention
« Reply #1 on: August 01, 2012, 02:30:03 AM »
Hi,

 ou can't reference scene's object in prefabs during editing time. So you need to create connections to other gameObjects of components at runtime, when the prefab starts for example.

bye,

 Jean