playMaker

Author Topic: Setting DOF Focal Transform to Spawned Prefab??  (Read 3877 times)

Col. Phil Bilko

  • Playmaker Newbie
  • *
  • Posts: 45
Setting DOF Focal Transform to Spawned Prefab??
« on: February 03, 2014, 12:53:52 PM »
Hello All;

I am wondering as I am a little stumped on this matter. I have a Main Camera with a DOF Script attached, and I have a player prefab that is spawned at the start, what I need to do is set the "focal transform" on the main camera's DOF script to the player prefab. This way the player is always in focus.

I had it set up where it did work on the first run then PM forgets the script it was linked too.

Any help is really appreciated!

Thanks

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Setting DOF Focal Transform to Spawned Prefab??
« Reply #1 on: February 04, 2014, 05:53:11 AM »
Hi,

 if you are using prefabs, that's to be expected, as prefabs can not reference objects in scenes.

You have to bind this at runtime, or maintain a global variable.

bye,

 Jean

Col. Phil Bilko

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Setting DOF Focal Transform to Spawned Prefab??
« Reply #2 on: February 04, 2014, 06:59:08 AM »
Hey Jean;

Thanks for the reply. Could you give me an example on how this would work for setting a transform from the prefab onto the DOF script though? I am not sure I get it.

Thanks

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Setting DOF Focal Transform to Spawned Prefab??
« Reply #3 on: February 04, 2014, 12:51:45 PM »
Hi,

 yes, Can you share this DOF script? Then I'll be able to do a working example.


bye,

 Jean

Col. Phil Bilko

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Setting DOF Focal Transform to Spawned Prefab??
« Reply #4 on: February 05, 2014, 06:08:41 AM »
Hello Jean;

Thanks for looking into this for me. I have attached the script.

I am trying to set the Focal Transform to my Player prefab.



jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Setting DOF Focal Transform to Spawned Prefab??
« Reply #5 on: February 07, 2014, 06:58:00 AM »
Hi,

 ok, I see: two options:

 create a fsm on the camera itself and create a global event "SET FOCAL TRANSFORM", from anywhere you like ( your prefab).

in your Fsm on that camera, then you can receive that global event, store the sender using the action "Get event info" and pick the "Sent by game object" property.

then you can use the action "set property" to set the transform to be the "Sent by game object". The trick however is to get the transform, not the gameobject as the focal script only accepts transforms, so you have to create a FsmObject or type transform and use the "get component" action to get to that.


this way you won't loose reference to the focal script cause you do that locally.

 IF you don't want to do that locally, you will have to use the action "Find GameObject" and reference the tag "MainCamera" and use that to set the focal distance using "Set property" action.

 I have attached the first variant, as it's nicer in my opinion. It requires Unity 4 Pro and Image Effects packages.

bye,

 Jean

Col. Phil Bilko

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Setting DOF Focal Transform to Spawned Prefab??
« Reply #6 on: February 07, 2014, 02:10:50 PM »
Odd it works in editor but not in the build..... Odd. Any ideas as to why?

Thanks for helping me with this btw. Much appreciated.
« Last Edit: February 07, 2014, 02:21:06 PM by Col. Phil Bilko »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Setting DOF Focal Transform to Spawned Prefab??
« Reply #7 on: February 10, 2014, 07:05:41 AM »
Hi,

 Works fine on web build. What platform are you publishin too? and are you sure about your quality settings? maybe they shunt the effect all together?

bye,

 Jean

Col. Phil Bilko

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Setting DOF Focal Transform to Spawned Prefab??
« Reply #8 on: February 10, 2014, 09:07:52 AM »
Hello;

I managed to get it to work. What I needed to do was on the Prefab that when it spawns / started it broadcasts a GET FOCAL POINT global event, which is attached to the camera's SET FOCAL POINT, which fires the events to set the cameras focal transform. Doing that it works like a dream but it fails in a mac build unless I do what's stated above.

Thanks for helping me out on this. So far it seems to work every time.
« Last Edit: February 10, 2014, 12:30:39 PM by Col. Phil Bilko »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Setting DOF Focal Transform to Spawned Prefab??
« Reply #9 on: February 11, 2014, 06:39:39 AM »
Hi,

 I think it's a mix up on your setup.

try with a simple scene first, then take it from there if that indeed works.

bye,

 Jean