playMaker

Author Topic: Getting Screen Point from a multiple camera scene  (Read 6262 times)

mweyna

  • Full Member
  • ***
  • Posts: 242
Getting Screen Point from a multiple camera scene
« on: February 13, 2014, 11:26:56 AM »
So I have two cameras in my scene, a UI 2d Camera, and a 3d Game Camera. I want to get the screen position from the 3d Camera, and feed that position data into an object under my NGUI 2d Camera. However, just using the normal Screen to World Point actions, it seems to just get the position data from the 2d Camera, so if I move my 3d camera around, the object remains in the same position (since the 2d Camera position technically hasn't changed). How should I approach this to get the right variables to the right FSMs?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Getting Screen Point from a multiple camera scene
« Reply #1 on: February 13, 2014, 11:42:12 PM »
Hi,

 What are you trying to achieve? if you want a ngui element to follow a 3d object, you should use existing components and tools ( the ngui HUD has this in store).

bye,

 Jean

mweyna

  • Full Member
  • ***
  • Posts: 242
Re: Getting Screen Point from a multiple camera scene
« Reply #2 on: February 14, 2014, 01:25:08 AM »
So I tried NGUI HUD, and have a UIFollowTarget on my GUI element - However, I can't seem to find a way to assign the Target property dynamically. See image -



Then on the FSM on the GUI Element, I have



Additionally, on my 3d Game Object I have the following FSM set up -



However, it doesn't seem to assign that game object variable to the script appropriately.

Right now, at runtime, the object gets created at the center of the screen. Assigned properly under the HUDText layer in my 2d UI Camera. And then does nothing. What am I doing wrong?
« Last Edit: February 14, 2014, 01:26:50 AM by mweyna »

mweyna

  • Full Member
  • ***
  • Posts: 242
Re: Getting Screen Point from a multiple camera scene
« Reply #3 on: February 14, 2014, 01:28:05 AM »
The end goal is to have something like this -



Where you have a tappable button on top of the 3d object.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Getting Screen Point from a multiple camera scene
« Reply #4 on: February 14, 2014, 05:05:40 AM »
Hi,

 I am confused, you seem to be mixing Unity GUI and NGUI? can you confirm?

using Unity GUI is very easy, the action GUILayoutAreayFollowObject works fine. do you have problems with this one in particular?

using UIFollow target: Assigning dynamically should simply be setting the "target". when I say simply.... since in PlayMaker you only can store GameObject, it's tricky but possible :)

http://hutonggames.com/playmakerforum/index.php?topic=6246.msg30566#msg30566

the link above will explain how to set a component "transform" property, and so you can apply this to work with UIFollow

bye,

 Jean

mweyna

  • Full Member
  • ***
  • Posts: 242
Re: Getting Screen Point from a multiple camera scene
« Reply #5 on: February 14, 2014, 04:16:35 PM »
Nope was trying to run this all through NGUI, not the built in Unity UI. So I tried the method you suggested in the other thread, having a global action that sets the GUILayout -




However, it doesn't seem to follow my object them either. What am I missing here? The Object the FSM is on is just a standard GUITexture UI Sprite (From default Unity, not NGUI) per your suggestion.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Getting Screen Point from a multiple camera scene
« Reply #6 on: February 17, 2014, 11:03:43 AM »
Hi,

 you have nothing in your follow area, you begin the area and then you end it.put a button and see where it is.

bye,

 Jean

mweyna

  • Full Member
  • ***
  • Posts: 242
Re: Getting Screen Point from a multiple camera scene
« Reply #7 on: February 19, 2014, 03:30:40 PM »
How would I define a scene game object to the Prefab UIFollow Target Script?

The field wants a defined transform and direct links to the camera objects, but I don't see how to assign them with a Set Property action.

redikann

  • Full Member
  • ***
  • Posts: 174
Re: Getting Screen Point from a multiple camera scene
« Reply #8 on: February 19, 2014, 04:41:48 PM »
Yes trying sandwiching your begin and end area
« Last Edit: February 19, 2014, 04:43:40 PM by redikann »