Playmaker Forum

PlayMaker Help & Tips => Android Help => Topic started by: zombie_farm on November 26, 2012, 11:37:06 AM

Title: Touch Object on different cam
Post by: zombie_farm on November 26, 2012, 11:37:06 AM
I have set up an ortho cam for my GUI and have normal objects(not GUI) in front of it that I need to touch and preform actions on. I can't get the touch object event to recognize my second cam.

Thanks!
Title: Re: Touch Object on different cam
Post by: kiriri on November 26, 2012, 12:58:38 PM
should be based on the main camera ("set main camera"), I think.

Cheers,
kiriri
Title: Re: Touch Object on different cam
Post by: zombie_farm on November 27, 2012, 12:03:04 PM
Isn't possible to fire a ray from both cams?.. I still have interactive elements in front of my main can. Its a story book for kids.
Title: Re: Touch Object on different cam
Post by: kiriri on November 27, 2012, 12:31:06 PM
well, sure it is but you have to do it manually.
First check for touches with the touch event action. Do this FSM on one object only in the entire scene. On touch,
 use set active camera (camera1), then use screen cast, then use set active camera (camera2) and then use screen cast again.
In both cases store the hit point. Then calculate both distances (get position (camera1) - hit point 1), same for camera 2.
Then compare the distances and find out which object is closer to the respective camera. The closer one should then be the one touched.
Then send a global event to the FSM on that object (like, "activateButton" or something similarily unique. If the object does not contain an FSM or if the global event is not inside, it'll complain but it won't cause any issues whatsoever in the compiled build)

If you use your second camera to layer a gui (or the like) on top of your first camera, you can also compare if the screencast of your gui camera returned as a hit object null ("Game Object Is Null"), and if it is, you can try the next screen cast on your second camera, and if it isn't you'll continue with that point/object.
That way it'll get whatever is on top of that par of the screen (whatever is rendered there, unless it's transparrent of course).

That's all I can think of off the spot. Hope it helps.

Best,
Sven
Title: Re: Touch Object on different cam
Post by: zombie_farm on November 28, 2012, 01:39:21 AM
Great thanks Sven!
Title: Re: Touch Object on different cam
Post by: zombie_farm on November 28, 2012, 12:22:22 PM
So I thought I had it. Can you just put that in order for me.
This is what I did
-checked for touch (touch event)
- I don't see a "screen cast" action
Thanks
Title: Re: Touch Object on different cam
Post by: kiriri on November 28, 2012, 12:59:11 PM
ah, there is no explicit screen cast action for a touch (will fix that whenever I'll find the time to), so you need to do this manually (again, isn't this fun? :D).
So a sceen cast is called a screen pick in PlayMaker. It makes a raycast from a certain position on your screen (= raycast based on camera) . So to get the right coordinates use a "Get touch info" and store the position as a vector2 (normalized of course). Then use the screen pick action from the coordinates you just touched. , switch camera and do another screen pick if needed.

I admit this is getting a bit advanced here, so don't hesitate to ask for every small info I may or may not have left out :) I know I'm pretty bad at explaining all of this.